Oracle uses Base64 des encryption to decrypt

Source: Internet
Author: User
Tags base64 decrypt

The base and DES encryption methods used in peacetime

For Des plus decryption, the key length is 8 bits, when the number of key bits entered is more than 8 bits automatic interception.

Baotou

Create or Replace package Pkg_compare is
function f_en_base64 (pi_str varchar2) return varchar2;
function f_de_base64 (pi_str varchar2) return varchar2;
Procedure P_decrypt_des
(
Pi_str VARCHAR2
, Pi_key VARCHAR2
, Po_encode out VARCHAR2
);
Procedure P_encrypt_des
(
Pi_str VARCHAR2
, Pi_key VARCHAR2
, Po_encode out VARCHAR2
);

End

Inclusion

Create or Replace package body Pkg_compare is
The/*base64 cryptographic function enters a string that needs to be encrypted, returning the encrypted string. */
function f_en_base64 (pi_str varchar2) return varchar2 is
OUT_BASE64 varchar2 (4000);
Begin
--Call system base64 conversion function
Select Utl_raw.cast_to_varchar2 (Utl_encode.base64_encode (Utl_raw.cast_to_raw (PI_STR)))
Into Out_base64
from dual;
return out_base64;
End

The/*base64 decryption function enters a string that needs to be decrypted, returning the decryption string. */
function f_de_base64 (pi_str varchar2) return varchar2 is
OUT_BASE64 varchar2 (4000);
Begin
--Call system base64 conversion function
Select Utl_raw.cast_to_varchar2 (Utl_encode.base64_decode (Utl_raw.cast_to_raw (PI_STR)))
Into Out_base64
from dual;
return out_base64;
End

/* Solution des stored Procedure */
Procedure P_decrypt_des
(
Pi_str VARCHAR2
, Pi_key VARCHAR2
, Po_encode out VARCHAR2
) is
NV_STR varchar2 (4000);

Begin

--Call des decryption system functions
Dbms_obfuscation_toolkit.desdecrypt (input_string = utl_raw.cast_to_varchar2 (PI_STR)
, key_string = Pi_key
, decrypted_string = NV_STR);
Po_encode: = RTrim (nv_str, Chr (0));

End
/*des Encryption */
Procedure P_encrypt_des
(
Pi_str VARCHAR2
, Pi_key VARCHAR2
, Po_encode out VARCHAR2
) is
NV_STR varchar2 (4000);
Raw_input Raw (128);
Key_input Raw (128);
Decrypted_raw Raw (2048);
Begin
NV_STR: = Rpad (Pi_str, (trunc (Length (PI_STR)/8) + 1) * 8, Chr (0));
Raw_input: = Utl_raw.cast_to_raw (NV_STR);
Key_input: = Utl_raw.cast_to_raw (Pi_key);
Dbms_obfuscation_toolkit.desencrypt (input = Raw_input
, key = Key_input
, encrypted_data = Decrypted_raw);
Po_encode: = Rawtohex (Decrypted_raw);
Return
End
End

Oracle uses Base64 des encryption to decrypt

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.