|
You might find this sample useful. It was originally supplied by Bruce Vining of the Rochester Lab. It uses prototypes for the MI functions and also deals with EBCDIC/ASCII issues. * Sample RPG code which takes into consideration the EBCDIC * to ASCII conversion, the hash generation, and the creation of a * suitable text string. The program assumes that EBCDIC means CCSID 37 * and ASCII CCSID 819. These assumptions may not hold true for all * languages. * Courtesy Bruce Vining via Midrange-L (June 27 2000) H DFTACTGRP(*NO) ACTGRP('QILE') BNDDIR('QC2LE') D Cipher PR EXTPROC('_CIPHER') D * VALUE D * VALUE D * VALUE D Convert PR EXTPROC('_XLATEB') D * VALUE D * VALUE D 10u 0 VALUE D cvthc PR EXTPROC('cvthc') D 1 D 1 D 10i 0 VALUE D Controls DS D Function 5i 0 inz(5) D HashAlg 1 inz(x'00') D Sequence 1 inz(x'00') D DataLngth 10i 0 inz(15) D Unused 8 inz(*LOVAL) D HashCtxPtr * inz(%addr(HashWorkArea)) D HashWorkArea S 96 inz(*LOVAL) D Msg S 50 D ReceiverHex S 16 D ReceiverPtr S * inz(%addr(ReceiverHex)) D ReceiverChr S 32 D SourcePtr S * inz(%addr(Msg)) D StartMap s 256 D To819 s 256 D CCSID1 s 10i 0 inz(37) D ST1 s 10i 0 inz(0) D L1 s 10i 0 inz(%size(StartMap)) D CCSID2 s 10i 0 inz(819) D ST2 s 10i 0 inz(0) D GCCASN s 10i 0 inz(0) D L2 s 10i 0 inz(%size(To819)) D L3 s 10i 0 D L4 s 10i 0 D FB s 12 D ds D x 5i 0 D LowX 2 2 * Get all single byte ebcdic hex values C 0 do 255 x C eval %subst(StartMap:x+1:1) = LowX C enddo * Get conversion table for 819 from 37 C call 'QTQCVRT' C parm CCSID1 C parm ST1 C parm StartMap C parm L1 C parm CCSID2 C parm ST2 C parm GCCASN C parm L2 C parm To819 C parm L3 C parm L4 C parm FB * Set message text C eval Msg = 'message digest' C eval DataLngth = %len(%trimr(Msg)) * Now Change Msg to 819 from 37 using MI C callp Convert( %addr(Msg) C :%addr(To819) C :%size(Msg)) * Get MD5 for Msg C callp Cipher( %addr(ReceiverPtr) C :%addr(Controls) C :%addr(SourcePtr)) * Convert nibbles to characters C callp cvthc( ReceiverChr C :ReceiverHex C :%size(ReceiverChr)) * Display the "proof" C ReceiverChr dsply C eval *INLR = '1' C return Jon Paris Partner400
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.