I am currently using DBMS_OBFUSCATION_TOOLKIT.MD5 for encryption and decryption. I want to impliment DBMS_CRYPTO.ENCRYPT_AES256, but I'm unsure how to do so. I'm unable to find appropriate examples online.
I currently have a package that entales a function that gets the hash, a procedure to add user, change_password, validate user, and to select a user. I want to use the same type of setup and the less change the better.
My DBMS_OBFUSCATION_TOOLKIT is located within my get_hash function.
Please help
Thank you
This is located within my package body:FUNCTION get_hash (username IN VARCHAR2, password IN VARCHAR2) RETURN VARCHAR2 AS BEGIN RETURN DBMS_OBFUSCATION_TOOLKIT.MD5( input_string => password); END get_hash;
OK, I was able to get the data into the encrypted data into the table. Now I want to be able to decrypt the data. Please see code.
I'm recieving the below errors
ORA-06502: PL/SQL: numeric or value error: hex to raw conversion error
ORA-06512: at "CDB.AP_PASSWORD_ENTRY_DECRYPT", line 24
ORA-06512: at line 7
Thanks
create or replacePROCEDURE AP_PASSWORD_ENTRY_DECRYPT(PARAM_1 IN NUMBER, PARAM_2 OUT VARCHAR2)AS input_string VARCHAR2 (200) := PARAM_2; output_string VARCHAR2 (200); encrypted_raw RAW (2000); -- stores encrypted binary text decrypted_raw RAW (2000); -- stores decrypted binary text num_key_bytes NUMBER := 256/8; -- key length 256 bits (32 bytes) key_bytes_raw RAW (32); -- stores 256-bit encryption key encryption_type PLS_INTEGER := -- total encryption type DBMS_CRYPTO.ENCRYPT_AES256 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5; p_username varchar2(200); p_password RAW(2000); BEGIN SELECT USERNAME, PASSWORD INTO p_username, p_password from USERS where ID = PARAM_1; key_bytes_raw := UTL_I18N.STRING_TO_RAW ( 'passwordpasswordpasswordpassword' ); decrypted_raw := SYS.DBMS_CRYPTO.DECRYPT ( src => UTL_I18N.RAW_TO_CHAR (p_password, 'AL32UTF8'), typ => encryption_type, key => key_bytes_raw ); PARAM_2 := decrypted_raw;END AP_PASSWORD_ENTRY_DECRYPT;
-- I got these magic numebrs above (1+256+4096) from another question posted on this forum.
However, when I try to substitute the 1 + 256 + 4096 which stands for DES + CBC + NoPadding with AES256 + CBC + PKCS5Padding, Oracle complains about the following Static values as invalid procedures:
DBMS_CRYPTO.ENCRYPT_AES256 (supposed to be integer)
DBMS_CRYPTO.CHAIN_CBC (integer)
DBMS_CRYPTO.PAD_PKCS5
http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:2886797089063