oracle 加密方案

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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值