Plex 2E

 View Only
Expand all | Collapse all

How to generate MD5 checksum on the iSeries

  • 1.  How to generate MD5 checksum on the iSeries

    Posted Dec 11, 2015 03:58 PM

    In 2016 I will need to generate an MD5 checksum on a file that will be going to the IRS.  I usually work with CA-2E, but any solution in RPG or Cobol would be appreciated.



  • 2.  Re: How to generate MD5 checksum on the iSeries

    Posted Dec 12, 2015 03:25 AM


  • 3.  Re: How to generate MD5 checksum on the iSeries

    Posted Dec 12, 2015 03:39 AM

    Incase plex people find this thread this is how i did this in java

     

     

    import java.io.File;

    import java.io.FileInputStream;

    import org.apache.commons.codec.digest.DigestUtils;

     

     

    &(2:).fromString(" ");

    &(3:).fromString(" ");

    &(4:).fromString(" ");

     

     

    try{

        //Open file

        byte[] buffer = new byte[(int) new File(&(1:).getValue()).length()];

        FileInputStream f = new FileInputStream(&(1:).getValue());   

        //Read filecontents into a ByteArray.

        f.read(buffer);

      //Calculate MD5 digest from the ByteArray

      &(2:).fromString(DigestUtils.md5Hex(buffer));

    }

    catch(Exception e)

    {

        //Output errorcode and cleartext.

        &(3:).fromString("ERR");

        &(4:).fromString(e.toString());

    }



  • 4.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 24, 2016 03:30 PM

    I tried the solution on the Scott Klement web page that you suggested.  That solution works for a "Message" or character string. I need a solution for a database file or even a stream file from the IFS.  I am transmitting XML data to the IRS from the iSeries, the IRS requirement is to provide them with an MD5 Checksum for the file.



  • 5.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 25, 2016 09:36 AM

    "To use that capability from my RPG program, I can use the IFS APIs to read a stream file one chunk at a time. For each chunk, I call the _CIPHER built-in function" Scott Klement  Utility to Calculate an MD5 Hash on a Stream File | RPG Programming content from iPro Developer



  • 6.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 25, 2016 10:51 AM

    I appreciate the tip.  I really didn't want to re-invent the wheel but it appears that might be required.  According to that article you referenced...   "You can download the source code for my iSeries MD5 utility from the following link:"

    http://www.pentontech.com/IBMContent/Documents/article/50931_22_Md5Sum.zip

    And of course that zip file does not exist.



  • 7.  Re: How to generate MD5 checksum on the iSeries

    Posted Dec 14, 2015 04:20 AM

    There is also some help here:

    http://www.mcpressonline.com/programming/rpg/create-an-md5-hash-using-rpg-and-sql.html

    A Google search for "MD5 checksum IBM i" will also find other useful information.



  • 8.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 25, 2016 12:07 PM

    Just out of curiosity, what are you sending to the IRS?  ACA 1094/1095 data?  If so, why not just upload the data via the web site?



  • 9.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 25, 2016 01:07 PM

    https://www.irs.gov/PUP/for_taxpros/software_developers/information_returns/Draft_Pub_5165_04_2015.pdf

     

    They do offer webservices but be warned looking at the specification they are not 'Hello World'. I have used https://www.scottklement.com/httpapi/ to accomplish consuming such services on the IBMi.



  • 10.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 25, 2016 04:46 PM

    Yes, it is for ACA 1094/1095 data.  I am working on an application for a company that is providing this tax reporting service for many clients/employers and employees.  It isn't something we do manually.  If you have not had the "opportunity" to read the IRS documents for ACA information returns I will tell you it is mindboggling... to put it lightly.  I suspect that is why the filing deadline was extended.  So I will press on with mind fully boggled.

     



  • 11.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 25, 2016 05:03 PM

    Webservices it is then?

     

    But then again "A comprehensive understanding of Web Service SOAP messaging is necessary in order to create software capable of transmitting data to the IRS." Personally I would take this route but if it was my first consumption of an external webservice it would be a a tall order especially as you are on the IBMi

     

    I see they use WS-Security or otherwise known as WS-DeathStar in the trade..I even had an open ticket with IBM B2B integration to support it.

    Nice link to others geting their heads around the webservices but will be much much much easier in java or C# http://stackoverflow.com/questions/35419472/sending-a-request-to-the-irs-aca-a2a-bulkrequesttransmitter-web-service



  • 12.  Re: How to generate MD5 checksum on the iSeries

    Posted Feb 29, 2016 12:20 PM

    Most likely I will not use webservices.  IBM offers a free tool for PASE that provides the capability to encode and decode Base64, as well as calculate MD5 and SHA-1 hashes. This tool works both interactively and from programs. This OpenSSL tool is part of the IBM Portable Utilities or i5/OS (5733-SC1) licensed program.

    For example, if you have this tool installed on your iSeries, you can produce the md5 checksum with a shell command like:

    openssl md5 < /ifs_path/mystream.file

    So this is the solution I will most likely use.  There is some good information at the following link:

    http://iprodeveloper.com/application-development/sha1-md5-and-base64-without-apis

     



  • 13.  Re: How to generate MD5 checksum on the iSeries

    Posted Jun 12, 2016 12:36 AM

    Hello GCox,

    Did you find anything better than strqsh ... openssl md5?

     

    I followed the iProDeveloper  SHA1 article you suggested. Good stuff but not quite right. The listing below uses the same concepts but calculates an MD5 hash that agrees with hash produced by a MD5sum Windows port and by the PASE shell  openssl md5  < path to file:

    PGM PARM(&DATA)

    DCL VAR(&DATA) TYPE(*CHAR) LEN(60)

    CHKOBJ OBJ(MD5OUT) OBJTYPE(*DTAARA)

    MONMSG CPF9801 EXEC(DO)

    CRTDTAARA  DTAARA(md5out) TYPE(*CHAR) LEN(32)

    ENDDO

    ADDENVVAR ENVVAR(MD5_INPUT) VALUE(&DATA) REPLACE(*YES)

    ADDENVVAR ENVVAR(QIBM_PASE_DESCRIPTOR_STDIO) VALUE(B) REPLACE(*YES)

    STRQSH CMD('export PATH=$PATH:/qopensys/usr/bin && openssl md5 < +

    $MD5_INPUT | iconv -f 819 -t 37 | sed "s/(stdin)=\ //" | datarea +

    -wl md5out')

    ENDPGM

     

    Leaves just the 32 byte hash in a current library/MD5OUT data area which can be accessed after the call to this CLP or CLLE.

    I'm running way behind schedule. Do you have any pointers for accessing the IRS ACA 1094/1095 software test system? At first glance their testing guide seems fairly obtuse.

     

    Best to you, ~ j