Hi Everyone,
Currently I have a scenario like Java will encrypt an image using
DES/CBC/PKCS5Padding with an 8 character length Key and IV they were using
in an array of data like IVBytesJpg = new byte[]{44, 140, (byte)146, 35,
26,(byte) 149, (byte)136, 150 } and store the encrypted image into an
Windows Share Drive (/WindosIP/Shared Drive/Image File).
I am accessing the Windows share drive from iSeries and decrypting the
image and exposing the image in base64 format in REST API.
To achieve this I am using the below steps
Step 1: Fetch the encrypted image from Windows Share drive using the below
code in rpgle (using QNTC)
dcl-s Wrk_WindowsImage sqltype(clob_file);
dcl-s Wrk_Image sqltype(clob:500000);
Wrk_WindowsImage_FO = SQFRD;
Wrk_WindowsImage_Name = /QNTC/WindosIP/Shared Drive/Image File
Wrk_WindowsImage_NL = %len(%trimr(Wrk_WindowsImage_Name));
exec sql values :Wrk_WindowsImage into :Wrk_Image;
This way I can fetch the encrypted image from Windows Share drive into an
CLOB variable
Step 2: Decrypt the Image
Using the IBMi API Qc3DecryptData and Algorithm Format as ALGD0200 and Key
Format as KEYD0200
In the algorithm ALGD0200, I am not sure how to use PKCS5Padding, So I am
just using the Pad option QC3PO as '0' (Do not remove padding).
I am not sure how can I use the array of data (IVBytesJpg = new byte[]{44,
140, (byte)146, 35, 26,(byte) 149, (byte)136, 150 }) as input for IV, if
someone shed some light it would be great.
Step 3: Convert the image into Base64 format
Convert the decrypted value in Base64 format. For this I am planning to use
Scott Klements Base64 utility (
https://www.scottklement.com/base64/)
Could you please help me out in how to use the PKCS5Padding and array of
data as IV in Qc3DecryptData API?
Regards,
Suren
As an Amazon Associate we earn from qualifying purchases.