SQL>
SQL> CREATE OR REPLACE FUNCTION get_enc_val (
2 p_in_val IN VARCHAR2,
3 p_key IN VARCHAR2,
4 p_iv IN VARCHAR2 := NULL
5 )
6 RETURN VARCHAR2
7 IS
8 l_enc_val RAW (4000);
9 l_enc_algo PLS_INTEGER;
10 l_in RAW (4000);
11 l_iv RAW (4000);
12 l_key RAW (4000);
13 l_ret VARCHAR2 (4000);
14 BEGIN
15 l_enc_algo := dbms_crypto.encrypt_3des;
16 l_in := utl_i18n.string_to_raw (p_in_val, 'AL32UTF8');
17 l_iv := utl_i18n.string_to_raw (p_iv, 'AL32UTF8');
18 l_key := utl_i18n.string_to_raw (p_key, 'AL32UTF8');
19 l_enc_val :=
20 dbms_crypto.encrypt (src => l_in,
21 KEY => l_key,
22 iv => l_iv,
23 typ => l_enc_algo
24 + dbms_crypto.chain_cbc
25 + dbms_crypto.pad_pkcs5
26 );
27 l_ret := RAWTOHEX (l_enc_val);
28 RETURN l_ret;
29 END;
30 /
Function created.
SQL>