Demonstrate DES3 encryption
SQL>
SQL> DECLARE
2 input_string VARCHAR2(160) := 'password01';
3 key_string VARCHAR2(24);
4
5 encrypted_string VARCHAR2(2048);
6 decrypted_string VARCHAR2(2048);
7 error_in_input_buffer_length EXCEPTION;
8 PRAGMA EXCEPTION_INIT(error_in_input_buffer_length, -28232);
9 INPUT_BUFFER_LENGTH_ERR_MSG VARCHAR2(100) := ' ';
10
11 BEGIN
12 input_string := input_string||input_string||input_string||input_string||input_string||input_string||input_string||input_string;
13 dbms_output.put_line('input string : ' || input_string);
14 dbms_obfuscation_toolkit.DES3GETKEY(which=>1, seed_string=>input_string,key=>key_string);
15 dbms_obfuscation_toolkit.DESENCRYPT(input_string => input_string,key_string => key_string, encrypted_string => encrypted_string );
16 dbms_output.put_line('encrypted string : ' ||encrypted_string);
17 dbms_obfuscation_toolkit.DESDecrypt(input_string => encrypted_string,key_string => key_string, decrypted_string => decrypted_string);
18 dbms_output.put_line('Decrypted output : ' ||decrypted_string);
19 if input_string = decrypted_string THEN
20 dbms_output.put_line('> DES Encryption and Decryption successful');
21 END if;
22 EXCEPTION
23 WHEN error_in_input_buffer_length THEN dbms_output.put_line('> ' || INPUT_BUFFER_LENGTH_ERR_MSG);
24 END;
25
26 /
PL/SQL procedure successfully completed.
SQL>
Related examples in the same category