midrange.com code scratchpad |
Name:
Decryption of encodedtokenexchange using OPENSSL AES128 Algorithm in RPGLE Program
|
Scriptlanguage:
Plain Text
|
Tabwidth:
4
|
Date:
11/19/2019 03:36:32 pm
|
IP:
Logged
|
|
Description:
Hi,
I tried below code instead of using data strructure still in testfile after decrypted value some stars are coming i want to remove them.
but desite using %trimr they are not getting removed yet.
|
Code:
- FUNIX IF F 1000 SPECIAL PGMNAME('UNIXCMD')
- F PLIST(UNIXPARM) USROPN
- F*QSYSPRT O F 1000 PRINTER
- dencodedExcha...
- dngeToken s 500 VARYING
-
- DPOS2 S 5U 0
- D cmd s 5000a
- D mode s 1A inz('P')
- D Åcommand s 512a
- d QCMDEXC PR ExtPgm('QCMDEXC')
- d command 500a const
- d clength 15p 5 const
-
- D record ds 1000
- D outrec s 1000 varying inz
-
- C UNIXPARM PLIST
- C PARM CMD
- C PARM MODE
- /free
- RECORD = *BLANKS;
- OUTREC = *BLANKS;
- XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/+
- INPUT.xml':'doc=file case=any path=+
- TokenExchangeResponse/encodedExchangeToken');
- eval encodedExchangeToken =%trimr(encodedExchangeToken);
- cmd = 'echo ' + '''' + encodedExchangeToken + ''' ! openssl +
- enc -d -aes-128-ecb -K 363631653237354f494d31554c594c4a +
- -nopad -nosalt -base64 -A';
- open UNIX;
- read UNIX record;
- dow not %eof(UNIX);
- eval record = %trimr(record);
- eval outrec = %trimr(record);
- eval outrec = %trimr(outrec);
- //Delete the TESTFILE
- Åcommand = 'DLTF FILE(rishi/TESTFILE)';
- QCMDEXC(%trim(Åcommand): %len(%trim(Åcommand)));
- Åcommand = *blanks;
- Åcommand = 'CRTPF FILE(RISHI/TESTFILE) RCDLEN(500)';
- QCMDEXC(%trim(Åcommand): %len(%trim(Åcommand)));
- //Write into file
- EXEC SQL
- INSERT INTO rishi/TESTFILE VALUES (:outrec);
- // dsply %subst(outrec:1:48);
- read UNIX record;
- enddo;
- close UNIX;
- *inlr = *on;
- /end-free
-
|
|
|