ORACLE資料加密(轉)

zhouwf0726發表於2019-06-11
ops$tkyte@DEV816> variable x varchar2(25)
ops$tkyte@DEV816>
ops$tkyte@DEV816> exec :x := 'How Now Brown Cow';

PL/SQL procedure successfully completed.

ops$tkyte@DEV816>
ops$tkyte@DEV816> declare
2 l_data varchar2(255);
3 begin
4 l_data := rpad( :x, (trunc(length(:x)/8)+1)*8, chr(0) );
5
6 dbms_obfuscation_toolkit.DESEncrypt
7 ( input_string => l_data,
8 key_string => 'MagicKey',
9 encrypted_string=> :x );
10 end;
11 /

PL/SQL procedure successfully completed.

ops$tkyte@DEV816>
ops$tkyte@DEV816> print x

X
-------------------------
òr?=eYw]e‘SW?:YD?ê?T?

ops$tkyte@DEV816>
ops$tkyte@DEV816> declare
2 l_data varchar2(255);
3 begin
4 dbms_obfuscation_toolkit.DESDecrypt
5 ( input_string => :x,
6 key_string => 'MagicKey',
7 decrypted_string=> l_data );
8
9 :x := rtrim( l_data, chr(0) );
10 end;
11 /

PL/SQL procedure successfully completed.

ops$tkyte@DEV816>
ops$tkyte@DEV816> print x

X
-------------------------
How Now Brown Cow

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-242352/,如需轉載,請註明出處,否則將追究法律責任。

相關文章