× 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.



It appears that the _CIPHER MI instruction does not support the SHA-256 hash algorithm:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/rzatk/CIPHER.htm

IBM probably decided to focus their effort on the more recent Calculate Hash (Qc3CalculateHash) API:
https://www.ibm.com/support/knowledgecenter/ssw_ibm_i_73/apis/qc3calha.htm

As documented, the Qc3CalculateHash API supports the MD5 as well as SHA-1 to SHA-512 hash algorithms, and will probably continue to be enhanced, if and when new algorithms are implemented. Some time ago I wrote a very simple Calculate Hash Value (CLCHASHVAL) command for the purpose of demonstrating how to call he Qc3CalculateHash API. The command processing program could easily be adapted to more specific requirements. If anyone are interested in a copy, please let me know.

Cheers,
Carsten

-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of Vernon Hamberg
Sent: 29. marts 2018 00:48
To: RPG programming on the IBM i (AS/400 and iSeries)
Subject: Re: MD5R4-SHA256

Raul

Nice use of 2 MI functions - I should have used _CIPHER in my webcast - for this one, at least, it's a very easy thing to use.

One thought - the Cipher prototype can be specified using standard variables, maybe like parmInput, instead of using pointers by value - if possible, it is preferable not to pass pointers by value, since there is no validation.

Also, you must have the dsControls structure defined somewhere else, right?

Again, nice example - thanks!
Vern

On 3/28/2018 9:35 AM, Raul Jager wrote:
I use a routine to get sha1,  changing the "HashAlgoritm will give you
sha256. (find _CIPER)

 // Return a SHA 1 as a 40-byte character value (hex) - input in
EBCDIC
PSHA1             B                   Export
DSHA1             PI            40
D parmInput                  32000    Options(*VarSize) Const Varying

     HashAlgorithm = x'01';
     HashWorkArea  = *LOVAL;
     DataLength=%Len(parmInput);
     Input=parmInput;
     Translate(DataLength: Input: 'QTCPASC');
     Cipher(%Addr(ptrOutput):
            %Addr(dsControls):
            %Addr(ptrInput));

     // Convert hash string to character
     cvthc(OutputHex:
           Output:
           %Size(OutputHex));
     Return %xlate('ABCDEF': 'abcdef': OutputHex);

PSHA1             E

// procedure to call MI

DCipher           PR                  EXTPROC('_CIPHER') D                                
*   VALUE D                                 *   VALUE D                                
*   VALUE


On Tue, Mar 27, 2018 at 10:12 AM, <broehmer@xxxxxxxxxxxxxxx> wrote:

Hi All,

I've a need to either change or find a program that does what Scott
Klement's program MD5R4 that creates a SHA1 hash to SHA256.
Anybody know what can be done
with
Scott's program
to make it work?

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
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.