Oracle Data encrypted

create or replace function encrypt_data(p_text varchar2, p_key varchar2) return varchar2 is
v_text varchar2(4000);
v_enc varchar2(4000);
begin
if p_text is null then
return null;
else
v_text := rpad(p_text, (trunc(lengthb(p_text)/8)+1)*8, chr(0));

sys.dbms_obfuscation_toolkit.desencrypt(
input_string => v_text,
key_string => p_key,
encrypted_string=>v_enc);

return v_enc;
end if;
end;
/

create or replace function decrypt_data(p_text varchar2, p_key varchar2) return varchar2 is
v_text varchar2(4000);
begin
if p_text is null then
return null;
else
sys.dbms_obfuscation_toolkit.desdecrypt(
input_string => p_text,
key_string => p_key,
decrypted_string=> v_text);

return rtrim(v_text,chr(0));
end if;
end;
/


你可能感兴趣的:(oracle,String,function,null,input)