Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Redirect URL Encryption issue

Attiq AhmedMay 1 2023

Hi,

I have an order page which needs to be integrated with Credit Card Payment solution. The pre-req is that the URL should be encrypted with AES_128.

I am not encountering any errors in the encryption anymore. However, its not being accepted by the third party and based on first analysis when I decryption the encrypted URL I get special characters

Any ideas why would this be happening ?

Decrypted Value = �j��l �Xg�չJ��"90&order_id=106&amount=44&currency=AED&redirect_url=www.ccavenue.ae

Code used for encryption

DECLARE

l_redirect_url VARCHAR2(4000);

encryption_type PLS_INTEGER :=

DBMS_CRYPTO.ENCRYPT_AES128

  • DBMS_CRYPTO.CHAIN_CBC

  • DBMS_CRYPTO.PAD_PKCS5;

key_bytes_raw RAW(16) := hextoraw('DB52ABCF09144F1F145607BEEF3C349A');

iv_raw RAW(16) := DBMS_CRYPTO.RANDOMBYTES(16);

encrypted_raw RAW(2000);

output_string VARCHAR2(4000);

BEGIN

-- Construct the ccAvenue redirect URL with the necessary parameters

l_redirect_url := l_redirect_url || '&merchant_id=45990';

l_redirect_url := l_redirect_url || '&order_id=' || :P3_ORDER_ID;

l_redirect_url := l_redirect_url || '&amount=' || :P3_AMOUNT;

l_redirect_url := l_redirect_url || '&currency=AED';

l_redirect_url := l_redirect_url || '&redirect_url=' || apex_util.prepare_url('www.ccavenue.ae');

encrypted_raw := DBMS_CRYPTO.ENCRYPT(

src => UTL_I18N.STRING_TO_RAW(l_redirect_url, 'AL32UTF8'),

typ => encryption_type,

key => key_bytes_raw,

iv => iv_raw

);

-- Convert the encrypted binary text to a hex string

output_string := RAWTOHEX(encrypted_raw);

-- Redirect the user to the ccAvenue payment page

apex_util.redirect_url(p_url =>

'https://secure.ccavenue.ae/transaction/transaction.do?command=initiateTransaction&access_code=AVUQ03GK18BR25QURB'

|| '&enc_request=' || output_string);

END;

Code used for Decryption

DECLARE

encrypted_raw RAW(2000) := HEXTORAW('C78EA00E35314861B25FC84B9A620B8736BC8AD408995DCDE20CA728FBFBEA6BAFB835A52BA4533ABD9AF389AEC09DED18F7262512DC1C138384B87143785C32E31D7EF1D975731BF84070809BD1ED4D9E56714BD08669C3152377A3D2A2D8DC');

encryption_type PLS_INTEGER := DBMS_CRYPTO.ENCRYPT_AES128 + DBMS_CRYPTO.CHAIN_CBC + DBMS_CRYPTO.PAD_PKCS5;

key_bytes_raw RAW(16) := hextoraw('DB52ABCF09144F1F145607BEEF3C349A');

iv_raw RAW(16) := DBMS_CRYPTO.RANDOMBYTES(16);

decrypted_raw RAW(2000);

decrypted_string VARCHAR2(4000);

BEGIN

decrypted_raw := DBMS_CRYPTO.DECRYPT(

src => encrypted_raw,

typ => encryption_type,

key => key_bytes_raw,

iv => iv_raw

);

-- Convert the decrypted binary text to a string

decrypted_string := UTL_I18N.RAW_TO_CHAR(decrypted_raw, 'AL32UTF8');

DBMS_OUTPUT.PUT_LINE(decrypted_string);

END;

Comments
Post Details
Added on May 1 2023
1 comment
384 views