SQL>
SQL> CREATE OR REPLACE FUNCTION get_dec_val (
2 p_in_val VARCHAR2,
3 p_key VARCHAR2,
4 p_iv VARCHAR2 := NULL,
5 p_which NUMBER := 0
6 )
7 RETURN VARCHAR2
8 IS
9 l_dec_val VARCHAR2 (2000);
10 l_iv VARCHAR2 (2000);
11 BEGIN
12 IF p_which = 0
13 THEN
14 IF LENGTH (p_key) < 16
15 THEN
16 raise_application_error(-20001,'Key length less than 16 for two-pass scheme');
17 END IF;
18 ELSIF p_which = 1
19 THEN
20 IF LENGTH (p_key) < 24
21 THEN raise_application_error(-20002,'Key length less than 24 for three-pass scheme');
22 END IF;
23 ELSE
24 raise_application_error (-20003,'Incorrect value of which '|| p_which|| '; must be 0 or 1');
25 END IF;
26
27 l_iv := RPAD (p_iv, (8 * ROUND (LENGTH (p_iv) / 8, 0) + 8));
28 l_dec_val :=
29 DBMS_OBFUSCATION_TOOLKIT.des3decrypt(input_string => UTL_RAW.cast_to_varchar2(HEXTORAW (p_in_val)),key_string => p_key,iv_string => l_iv,which => p_which);
30 RETURN RTRIM (l_dec_val);
31 END;
32 /
Function created.
SQL>
|