decrypt function - not showing readable string
I have created this function for decrypt a password and its 开发者_StackOverflow社区working but is showing strange characters like this ��5d[���������
. I'm using oracle xe 10g
create or replace
function decrypt (val VARCHAR) return varchar2 is
input_string varchar2(2048) := val;
key_string VARCHAR2(10) := 'xpto';
decrypted_string VARCHAR2(2048);
begin
dbms_output.put_line(input_string);
dbms_obfuscation_toolkit.DESDecrypt(
input_string => input_string,
key_string => key_string,
decrypted_string => decrypted_string );
dbms_output.put_line('> decrypted string output : ' || decrypted_string);
return decrypted_string;
end;
What i'm i doing wrong it should appear a readable string.
Why would you need to decode a password? Why not store it hashed?
There are a few constraints with the size of the input string and the key size as well (explained in the online doc).
Here's a working example with Oracle 10.2.0.3:
SQL> VARIABLE v_in VARCHAR2(64);
SQL> VARIABLE v_enc VARCHAR2(64);
SQL> VARIABLE v_out VARCHAR2(64);
SQL> DECLARE
2 l_key VARCHAR2(8) := rpad('my_key', 8, 'x'); -- 64-bit key
3 BEGIN
4 -- input size must be a multiple of 8 bytes
5 :v_in := '12345678';
6 :v_enc := dbms_obfuscation_toolkit.desEncrypt(input_string => :v_in,
7 key_string => l_key);
8 :v_out := dbms_obfuscation_toolkit.desDecrypt(input_string => :v_enc,
9 key_string => l_key);
10 END;
11 /
PL/SQL procedure successfully completed
v_in
---------
12345678
v_enc
---------
þæHI«Ó¹-
v_out
---------
12345678
精彩评论