Demonstrate DES3 encryption : dbms_obfuscation_toolkit « System Packages « Oracle PL/SQL Tutorial

Home
Oracle PL/SQL Tutorial
1.Introduction
2.Query Select
3.Set
4.Insert Update Delete
5.Sequences
6.Table
7.Table Joins
8.View
9.Index
10.SQL Data Types
11.Character String Functions
12.Aggregate Functions
13.Date Timestamp Functions
14.Numerical Math Functions
15.Conversion Functions
16.Analytical Functions
17.Miscellaneous Functions
18.Regular Expressions Functions
19.Statistical Functions
20.Linear Regression Functions
21.PL SQL Data Types
22.PL SQL Statements
23.PL SQL Operators
24.PL SQL Programming
25.Cursor
26.Collections
27.Function Procedure Packages
28.Trigger
29.SQL PLUS Session Environment
30.System Tables Data Dictionary
31.System Packages
32.Object Oriented
33.XML
34.Large Objects
35.Transaction
36.User Privilege
Oracle PL/SQL Tutorial » System Packages » dbms_obfuscation_toolkit 
31.16.3.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>
31.16.dbms_obfuscation_toolkit
31.16.1.dbms_obfuscation_toolkit.DES3Decrypt
31.16.2.dbms_obfuscation_toolkit.DES3GETKEY and dbms_obfuscation_toolkit.DES3ENCRYPT
31.16.3.Demonstrate DES3 encryption
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.