SQL> connect / as sydba
SQL> grant execute on DBMS_CRYPTO to public;
CREATE OR REPLACE FUNCTION WEB_USER.FNC_ENCRYPT_PW (V_IN_STRING VARCHAR2) RETURN RAW
IS
INPUT_RAW RAW (1024);
KEY_RAW RAW (16) := UTL_RAW.CAST_TO_RAW ('gctjdxkstjdxksgc');
V_OUT_RAW RAW (1024);
AES_CBC_PKCS5 CONSTANT PLS_INTEGER
:= DBMS_CRYPTO.ENCRYPT_AES128
+ DBMS_CRYPTO.CHAIN_CBC
+ DBMS_CRYPTO.PAD_PKCS5;
BEGIN
INPUT_RAW := UTL_I18N.STRING_TO_RAW (V_IN_STRING, 'AL32UTF8');
V_OUT_RAW := DBMS_CRYPTO.ENCRYPT (SRC => INPUT_RAW,
TYP => AES_CBC_PKCS5,
KEY => KEY_RAW);
RETURN V_OUT_RAW;
END FNC_ENCRYPT_PW;
/
CREATE OR REPLACE FUNCTION WEB_USER.FNC_DECRYPT_PW (V_IN_RAW RAW) RETURN VARCHAR2
IS
KEY_RAW RAW (16) := UTL_RAW.CAST_TO_RAW ('gctjdxkstjdxksgc');
OUTPUT_RAW RAW (1024);
V_OUT_STRING VARCHAR2 (1024);
AES_CBC_PKCS5 CONSTANT PLS_INTEGER
:= DBMS_CRYPTO.ENCRYPT_AES128
+ DBMS_CRYPTO.CHAIN_CBC
+ DBMS_CRYPTO.PAD_PKCS5;
BEGIN
OUTPUT_RAW := DBMS_CRYPTO.DECRYPT ( SRC => V_IN_RAW,
TYP => AES_CBC_PKCS5,
KEY => KEY_RAW);
V_OUT_STRING := UTL_I18N.RAW_TO_CHAR (OUTPUT_RAW, 'AL32UTF8');
RETURN V_OUT_STRING;
END FNC_DECRYPT_PW;
/
SQL> connect web_user/web_pass$
SQL> select PW_ENCRYPT('abcdefg') from dual;