dbms_obfuscation_toolkit.DES3GETKEY and dbms_obfuscation_toolkit.DES3ENCRYPT : dbms_obfuscation_toolkit « System Packages « Oracle PL/SQL Tutorial






SQL> -- create demo table
SQL> create table emp(
  2    ID                 VARCHAR2(4 BYTE)         NOT NULL,
  3    fname         VARCHAR2(10 BYTE),
  4    lname          VARCHAR2(10 BYTE),
  5    Start_Date         DATE,
  6    End_Date           DATE,
  7    Salary             Number(8,2),
  8    City               VARCHAR2(10 BYTE),
  9    Description        VARCHAR2(15 BYTE)
 10  )
 11  /

Table created.

SQL>
SQL>
SQL>
SQL> CREATE or REPLACE TRIGGER ccn_encrypt_trig
  2  BEFORE INSERT or UPDATE of fname on emp
  3  FOR EACH ROW
  4  DECLARE
  5     v_key VARCHAR2(80);
  6     v_seed VARCHAR2(80) := '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
  7     v_encrypted_string VARCHAR2(2048);
  8  BEGIN
  9        dbms_obfuscation_toolkit.DES3GETKEY(which=>1, seed_string=>v_seed,key=>v_key);
 10        dbms_obfuscation_toolkit.DES3ENCRYPT(input_string => RPAD(:NEW.fname,16,' '), key_string => v_key, encrypted_string => v_encrypted_string );
 11  END;
 12  /

Trigger created.

SQL>
SQL> -- prepare data
SQL> insert into emp(ID,  fname, lname, Start_Date,                     End_Date,                       Salary,  City,       Description)
  2               values ('01','Jason',    'Martin',  to_date('19960725','YYYYMMDD'), to_date('20060725','YYYYMMDD'), 1234.56, 'Toronto',  'Programmer')
  3  /
insert into emp(ID,  fname, lname, Start_Date,                     End_Date,
                   Salary,  City,       Description)
            *
ERROR at line 1:
ORA-28237: seed length too short
ORA-06512: at "SYS.DBMS_OBFUSCATION_TOOLKIT_FFI",
line 3
ORA-06512: at "SYS.DBMS_OBFUSCATION_TOOLKIT", line 76
ORA-06512: at "JAVA2S.CCN_ENCRYPT_TRIG", line 6
ORA-04088: error during execution of trigger
'JAVA2S.CCN_ENCRYPT_TRIG'


SQL>
SQL> drop table emp;

Table dropped.

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