Creato da pastuweb.com
Share My Page
My Social Accounts
Account FaceBook Account LinkedIn Account Twitter Account Google Plus Account Git Hub

Here there is the package that you can include in your database:

The padding is very important because the input string must be a multiple of 8 bytes

cifra = ENCRYPT
decifra = DECRYPT

CREATE OR REPLACE PACKAGE  <user>.PCK_CIFRATURA AS

  FUNCTION cifra(inputValue in varchar2, chiave in varchar2) RETURN RAW;
  FUNCTION decifra(inputValue in RAW, chiave in varchar2) RETURN VARCHAR2;
  
END PCK_CIFRATURA;

 


CREATE OR REPLACE PACKAGE BODY <user>.PCK_CIFRATURA AS

  FUNCTION cifra(inputValue in varchar2, chiave in varchar2) RETURN RAW 
   is
    vEncrypted VARCHAR2(2048);
    vTemp VARCHAR2(2048);
  begin
       -- add padding "#"
    vTemp := RPAD (inputValue, (8 * ROUND (LENGTH (inputValue) / 8, 0) + 8), '#');
    dbms_obfuscation_toolkit.desencrypt (input_string => vTemp,key_string
=> chiave,

encrypted_string => vEncrypted);

    
    return UTL_RAW.CAST_TO_RAW(vEncrypted);
  end cifra;
  
  FUNCTION decifra(inputValue in RAW, chiave in varchar2) RETURN VARCHAR2
   is
    raw_input_value     VARCHAR2(2048) := UTL_RAW.CAST_TO_VARCHAR2(inputValue);
    vTemp VARCHAR2(2048);
    vDecrypted VARCHAR2(2048);
  begin
       
    DBMS_OBFUSCATION_TOOLKIT.DESDECRYPT (input_string => raw_input_value,

key_string => chiave,decrypted_string => vDecrypted);
    -- delete padding
    vTemp := replace (vDecrypted,'#','');
    
    return vTemp;
  end decifra;


END PCK_CIFRATURA;
/

Average (1 Vote)
The average rating is 5.0 stars out of 5.