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:
  1.      FUNIX      IF   F 1000        SPECIAL PGMNAME('UNIXCMD')
  2.      F                                     PLIST(UNIXPARM) USROPN
  3.      F*QSYSPRT   O    F 1000        PRINTER
  4.      dencodedExcha...
  5.      dngeToken         s            500    VARYING
  6.  
  7.      DPOS2             S              5U 0
  8.      D cmd             s           5000a
  9.      D mode            s              1A   inz('P')
  10.      D Åcommand        s            512a
  11.      d QCMDEXC         PR                  ExtPgm('QCMDEXC')
  12.      d   command                    500a   const
  13.      d   clength                     15p 5 const
  14.  
  15.      D record          ds          1000
  16.      D outrec          s           1000    varying  inz
  17.  
  18.      C     UNIXPARM      PLIST
  19.      C                   PARM                    CMD
  20.      C                   PARM                    MODE
  21.       /free
  22.        RECORD = *BLANKS;
  23.        OUTREC = *BLANKS;
  24.        XML-INTO encodedExchangeToken %XML('/home/I0RS01HU/+
  25.        INPUT.xml':'doc=file case=any path=+
  26.        TokenExchangeResponse/encodedExchangeToken');
  27.        eval encodedExchangeToken =%trimr(encodedExchangeToken);
  28.        cmd = 'echo ' + '''' +  encodedExchangeToken + ''' ! openssl +
  29.           enc -d -aes-128-ecb -K 363631653237354f494d31554c594c4a +
  30.           -nopad -nosalt -base64 -A';
  31.        open UNIX;
  32.        read UNIX record;
  33.        dow not %eof(UNIX);
  34.        eval record = %trimr(record);
  35.        eval outrec = %trimr(record);
  36.        eval outrec = %trimr(outrec);
  37.         //Delete the TESTFILE
  38.           Åcommand = 'DLTF FILE(rishi/TESTFILE)';
  39.           QCMDEXC(%trim(Åcommand): %len(%trim(Åcommand)));
  40.           Åcommand = *blanks;
  41.           Åcommand = 'CRTPF FILE(RISHI/TESTFILE) RCDLEN(500)';
  42.           QCMDEXC(%trim(Åcommand): %len(%trim(Åcommand)));
  43.         //Write into file
  44.            EXEC SQL
  45.           INSERT INTO rishi/TESTFILE VALUES (:outrec);
  46.         // dsply %subst(outrec:1:48);
  47.            read UNIX record;
  48.            enddo;
  49.         close UNIX;
  50.         *inlr = *on;
  51.       /end-free
  52.  
© 2004-2019 by midrange.com generated in 0.006s valid xhtml & css