Oracle 3DES加密樣本

來源:互聯網
上載者:User

標籤:

SET SERVEROUTPUT ON;DECLARE  input_string  VARCHAR2(32) := ‘12345678‘;  ikey          INTEGER := 100001;  input_raw     RAW(32) := UTL_RAW.CAST_TO_RAW(input_string);  key_raw       RAW(32);  encrypted_raw RAW(32);  encry_key     VARCHAR2(32);  decrypted_raw RAW(32);BEGIN  key_raw := utl_raw.cast_from_binary_integer(ikey) ||             utl_raw.bit_complement(utl_raw.cast_from_binary_integer(ikey));  key_raw := key_raw || utl_raw.bit_xor(key_raw, hextoraw(‘F0F0F0F0F0F0F0F0‘));  dbms_output.put_line(‘> ========= Get Key Bytes =========‘);  dbms_output.put_line(‘> Input String: ‘ || input_string);  dbms_output.put_line(‘> Key   String: ‘ || key_raw);  dbms_output.put_line(‘> Key   length: ‘ || UTL_RAW.length(key_raw));  dbms_output.put_line(‘> ========= BEGIN TEST Encrypt =========‘);  --加密  encrypted_raw := dbms_obfuscation_toolkit.DES3Encrypt(input => input_raw,                                                        key   => key_raw,                                                        iv    => hextoraw(‘0000000000000000‘));  dbms_output.put_line(‘> encrypted_raw output: ‘ || encrypted_raw);  encry_key := utl_raw.cast_to_varchar2(utl_encode.base64_encode(encrypted_raw));  dbms_output.put_line(‘> encry_key     output: ‘ || encry_key);    --解密  decrypted_raw := dbms_obfuscation_toolkit.DES3Decrypt(input => encrypted_raw,                                                        key   => key_raw,                                                        iv    => hextoraw(‘0000000000000000‘));  dbms_output.put_line(‘> decrypted_raw output: ‘ || utl_raw.cast_to_varchar2(decrypted_raw));  IF input_string = utl_raw.cast_to_varchar2(decrypted_raw) THEN    dbms_output.put_line(‘> String DES Encyption and Decryption successful‘);  END IF;END;/

顯示如下:

> ========= Get Key Bytes =========
> Input String: 12345678
> Key   String: 000186A1FFFE795EF0F176510F0E89AE
> Key   length: 16
> ========= BEGIN TEST Encrypt =========
> encrypted_raw output: 9D2A9569D15A07DB
> encry_key     output: nSqVadFaB9s=
> decrypted_raw output: 12345678
> String DES Encyption and Decryption successful
PL/SQL procedure successfully completed

Oracle 3DES加密樣本

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.