Thursday, September 29, 2011

PLSQL:Encryption Decryption DBMS_CRYPTO

set serveroutput on

DECLARE
LC$Source VARCHAR2(19) := 'Music is the best!';
LR$Source RAW(128) := utl_raw.cast_to_raw(LC$Source);
LR$Key RAW(128) := utl_raw.cast_to_raw('FrankZappa');
LR$Crypted RAW(2048);
LR$Decrypted RAW(2048);

BEGIN

dbms_output.put_line('Source string : ' || LC$Source);

LR$Crypted := dbms_crypto.encrypt(LR$Source,
dbms_crypto.des_cbc_pkcs5, LR$Key);

dbms_output.put_line('Encrypted raw : ' ||
RAWTOHEX(utl_raw.cast_to_raw(LR$Crypted)));

LR$Decrypted := dbms_crypto.decrypt(src => LR$Crypted,
typ => dbms_crypto.des_cbc_pkcs5, key => LR$Key);

dbms_output.put_line('Decrypted string : ' ||
utl_raw.cast_to_varchar2(LR$Decrypted));
END;
/

1 comment:

Anonymous said...

Wow, this piece of writing is pleasant, my younger sister is analyzing
these things, therefore I am going to inform her.


Visit my blog; San Diego probate attorney