create or replace function f_get_passboy_decode
(
p_cfg_no Int DEFAULT 0 --配置项编号
)
return HstypeChar256
as
v_cfg_no Int := nvl(p_cfg_no,0); --配置项编号
v_result Char2000; --返回结果值
v_error_no NumID;
v_error_info Char500;
v_error_pathinfo Char500;
v_error_pathinfo_tmp Char500; --错误路径临时变量
v_input VARCHAR2(100) := '12345678';
v_key VARCHAR2(100) := 'oracle9i';
-- ORA-28232: obfuscation 工具箱的输入长度无效(原因是加密字符串必须是8的倍数)
encrypted_str VARCHAR2(4000);
decrypted_str VARCHAR2(4000);
encrypted_raw RAW(4000);
decrypted_raw RAW(4000);
begin
v_result := '00' ;
v_error_no := 0 ;
v_error_info := ' ' ;
v_error_pathinfo := ' ' ;
v_error_pathinfo := substr(v_error_pathinfo || '-->f_get_dm_config',1,500);
v_error_pathinfo_tmp := v_error_pathinfo;
-- string类型加密解密
-- encrypt(string)
dbms_obfuscation_toolkit.desencrypt(input_string => v_input, key_string => v_key, encrypted_string => encrypted_str);
dbms_output.put_line('Encrypted string: ' || encrypted_str);
dbms_output.put_line('Encrypted hex value: ' || utl_raw.cast_to_raw(encrypted_str));
-- decrypt(string)
dbms_obfuscation_toolkit.desdecrypt(input_string => encrypted_str, key_string => v_key, decrypted_string => decrypted_str);
dbms_output.put_line('Decrypted String: ' || decrypted_str);
-- raw类型加密解密
-- encrypt(raw)
dbms_obfuscation_toolkit.desencrypt(input => utl_raw.cast_to_raw(v_input), key => utl_raw.cast_to_raw(v_key), encrypted_data => encrypted_raw);
dbms_output.put_line('Encrypted Raw: ' || encrypted_raw);
dbms_output.put_line('Encrypted hex value: ' || rawtohex(encrypted_raw));
-- decrypt(raw)
dbms_obfuscation_toolkit.desdecrypt(input => encrypted_raw, key => utl_raw.cast_to_raw(v_key), decrypted_data => decrypted_raw);
dbms_output.put_line('Decrypted String: ' || utl_raw.cast_to_varchar2(decrypted_raw));
select '000' into v_result from dual;
return v_result;
exception when others then
v_result := '0';
return v_result;
end f_get_passboy_decode;