← Tutti gli articoli
Encrypt & Decrypt password in PLSQL - Oracle 10g
04 October 2010 ·
PLSQL · Article ·
32 visite
Encrypt & Decrypt password in PLSQL - Oracle 10g
PACKAGE BODY XX_PASSWORD AS
-- key must be exactly 8 bytes long
c_encrypt_key varchar2(8) := 'key45678';
function encrypt (i_password varchar2) return varchar2 is
v_encrypted_val varchar2(38);
v_data varchar2(38);
begin
-- Input data must have a length divisible by eight
v_data := RPAD(i_password,(TRUNC(LENGTH(i_password)/8)+1)*8,CHR(0));
DBMS_OBFUSCATION_TOOLKIT.DESENCRYPT(
input_string => v_data,
key_string => c_encrypt_key,
encrypted_string => v_encrypted_val);
return v_encrypted_val;
end encrypt;
function decrypt (i_password varchar2) return varchar2 is
v_decrypted_val varchar2(38);
begin
DBMS_OBFUSCATION_TOOLKIT.DESDECRYPT(
input_string => i_password,
key_string => c_encrypt_key,
decrypted_string => v_decrypted_val);
return v_decrypted_val;
end decrypt;
end XX_PASSWORD;
select xx_password.encrypt('PASSWORD1') from dual;
select xx_password.decrypt(app_password.encrypt('PASSWORD1')) from dual;
select xx_password.encrypt('PSW2') from dual;
select xx_password.decrypt(xx_password.encrypt('PSW2')) from dual;
select xx_password.encrypt('PASSWORD1') from dual;
select xx_password.decrypt(app_password.encrypt('PASSWORD1')) from dual;
select xx_password.encrypt('PSW2') from dual;
select xx_password.decrypt(xx_password.encrypt('PSW2')) from dual; For more information go to http://arunrathod.blogspot.com/2008/09/script-to-encrypt-and-decrypt-using.html