create or replace package PG_ENCRYPT_DECRYPT
is
iKey varchar2(8):= oracle9i .
function GEN_RAW_KEY ( iKey in varchar2) return raw.
function DECRYPT_3KEY_MODE(iValue in raw,iMode in pls_integer)return varchar2.
function ENCRYPT_3KEY_MODE(iValue in varchar2,iMode in pls_integer)return raw.
function FormatStr(iValue in varchar2)return varchar2.
function FormatStr2(iValue in varchar2)return varchar2.
end.
/////////
create or replace package body PG_ENCRYPT_DECRYPT
is
function GEN_RAW_KEY ( iKey in varchar2)
return raw
as
rawkey raw(240) := .
begin
for i in 1..length(iKey) loop
rawkey := rawkey||hextoraw(to_char(ascii(substr(iKey, i, 1)))).
end loop.
return rawkey.
end GEN_RAW_KEY.
/* Creating function DECRYPT_3KEY_MODE*/
FUNCTION DECRYPT_3KEY_MODE ( iValue in raw, iMode in pls_integer)return varchar2
as
vDecrypted varchar2(4000).
rawkey raw(240) := .
begin
rawkey := GEN_RAW_KEY(iKey).-- decrypt input string
vDecrypted := dbms_obfuscation_toolkit.des3decrypt (UTL_RAW.CAST_TO_VARCHAR2(iValue), key_string => rawkey, which => iMode).
return FormatStr2(vDecrypted).
end DECRYPT_3KEY_MODE.
/*Creating function ENCRYPT_3KEY_MODE*/
FUNCTION ENCRYPT_3KEY_MODE ( iValue in varchar2, iMode in pls_integer)return raw
as
vEncrypted varchar2(4000).
vEncryptedRaw Raw(2048).
rawkey raw(240) := .
begin
rawkey := GEN_RAW_KEY(iKey).-- encrypt input string
vEncrypted := dbms_obfuscation_toolkit.des3encrypt (FormatStr(iValue), key_string => rawkey, which => iMode).
-- convert to raw as out
vEncryptedRaw := UTL_RAW.CAST_TO_RAW(vEncrypted).
return vEncryptedRaw.
end ENCRYPT_3KEY_MODE.
相关文章
Window erver2008:最后的32位系统
WindowsVista中如何按日期查找图片
确定XP退市时间09年2月停止授权
解决Oracle处理中文乱码的一种方法
oracle用存储过程加密一段字符串(3des算法)
Linux攻略常用的网络安全工具详细介绍
Linux命令:改变文件或目录的访问权限
RedHatEnterpriseLinux4的应用软件
Linux的奇思妙想之系统优化技巧全接触
澳大利亚华人论坛
考好网
日本华人论坛
华人移民留学论坛
英国华人论坛