× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Charles,

I believe this must be the source you are searching for:

//
// RPG Service Program: MD5R
// Create an MD5 hash for a given piece of data (aka message or
digest)
//
http://www.mcpressonline.com/programming/rpg/create-an-md5-hash-using-rpg-and-sql.html
// Michael Sansoterra
//
//
// Compile Notes
// 1. CRTRPGMOD
// 2. CRTSRVPGM SRVPGM(MYLIB/MD5R) EXPORT(*ALL)
//
// http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?top
// ic=/rzatk/CIPHER
//
// CREATE FUNCTION MD5HASH_BINARY(DATA VARCHAR(32000) CCSID 1208)
// RETURNS BINARY(16)
// LANGUAGE RPGLE
// EXTERNAL NAME 'MYLIB/MD5R(MD5HASH_BINARY)'
// PARAMETER STYLE GENERAL
// DETERMINISTIC
// NOT FENCED
//
// CREATE FUNCTION MD5HASH_HEX(DATA VARCHAR(32000) CCSID 1208)
// RETURNS CHAR(32) CCSID 37
// LANGUAGE RPGLE
// EXTERNAL NAME 'MYLIB/MD5R(MD5HASH_HEX)'
// PARAMETER STYLE GENERAL
// DETERMINISTIC
// NOT FENCED
//
// select md5hash_binary('mypassword') from qsqptabl
// select Hex(md5hash_binary('mypassword')) from qsqptabl
// select md5hash_hex('mypassword') from qsqptabl
//
// SQL Server Comparison:
// Select HASHBYTES('md5','mypassword')
//
// 0x34819D7BEEABB9260A5C854BC85B3E44
//
//
HNOMAIN OPTION(*SRCSTMT:*NODEBUGIO) BndDir('QC2LE')
HOPTIMIZE(*FULL)
DCipher PR EXTPROC('_CIPHER')
D * VALUE
D * VALUE
D * VALUE
Dcvthc PR EXTPROC('cvthc')
D 1
D 1
D 10i 0 VALUE
DMD5Hash_BINARY PR 16
D parmInput 32000 Options(*VarSize) Const Varying
DMD5Hash_HEX PR 32
D parmInput 32000 Options(*VarSize) Const Varying

// Return a hash as a 16-byte binary value
PMD5Hash_BINARY B Export
DMD5Hash_BINARY PI 16
D parmInput 32000 Options(*VarSize) Const Varying

DInput S 32000
DptrInput S * Inz(%Addr(Input))

DOutput S 16
DptrOutput S * Inz(%Addr(Output))

DdsControls DS 96
D Function 5U 0 Inz(5)
D HashAlgorithm 1 Inz(x'00')
D Sequence 1 Inz(x'00')
D DataLength 10U 0
D OutputType 1 Inz(x'00')
D Reserved1 7 Inz(*ALLx'00')
D ptrHashContext * Inz(%Addr(HashWorkArea))
DHashWorkArea S 96 Inz(*LOVAL)

/Free
DataLength=%Len(parmInput);
Input=parmInput;
Cipher(%Addr(ptrOutput):
%Addr(dsControls):
%Addr(ptrInput));

Return Output;
/End-Free
P E

// Return a hash as a 32-byte character value (hex)
PMD5Hash_HEX B Export
DMD5Hash_HEX PI 32
D parmInput 32000 Options(*VarSize) Const Varying

DOutput S 16
DOutputHex S 32

/Free
Output=MD5Hash_Binary(parmInput);
// Convert hash string to character
cvthc(OutputHex:
Output:
%Size(OutputHex));

Return OutputHex;
/End-Free
P E

*----------------------------------

HTH,
Luis Rodriguez


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.