RPGIV @ Work

A unique site for RPG and System i Lovers


Hi, this site will provide all what you need in System i and RPG developments.

My Name is Chamara Withanachchi, System i Expert and RPG Developer. And in the field for last 11 years.

I hope you will find lot of valuable information from this site

Generate Hash total using SHA1 Algo. and show in ASCII format Print E-mail
User Rating: / 1
Written by Chamara Withanachchi   
  * -----------------------------------------------------------------
  * Author      : Chamara Withanachchi                              *
  * Date        : 2008/05/04                                        *
  * Description : Generate Hash total using SHA1 Algo.              *
  *                                                                 *
  * -----------------------------------------------------------------
 D Qc3CalculateHash...                                               
 D                 PR                  ExtProc('Qc3CalculateHash')   
 D   InData                        *   value                         
 D   IndataL                     10i 0 const                         
 D   InDataF                      8a   const                         
 D   AlgoDes                     16a   const                         
 D   AlgoFmt                      8a   const                         
 D   CryptoSP                     1a   const                         
 D   CryptoDev                    1a   const options(*omit)          
 D   Hash                        64a   options(*varsize:*omit)       
 D   ErrorCode                32767a   options(*varsize)             
 D ALGD0500_t      ds                  qualified                     
 D                                     based(Template)               
 D   HashAlg                     10i 0                               
 D QDCXLATE        PR                  ExtPgm('QDCXLATE')      
 D   len                          5p 0 const                   
 D   data                     32702a   options(*varsize)       
 D   table                       10a   const                   
 D cvthc           PR                  ExtProc('cvthc')        
 D   target                   65534A   options(*varsize)       
 D   src_bits                 32767A   options(*varsize) const 
 D   tgt_length                  10I 0 value                   
 D ErrorNull       ds                  qualified               
 D    BytesPro                   10i 0 inz(0)                  
 D    BytesAvai                  10i 0 inz(0)                  
 D HASH_SHA1       c                   2                       
 D data            s             80A                           
 D len             s             10i 0                         
 D alg             ds                  likeds(ALGD0500_t)      
 D bin             s             20a                           
 D hex             s             40a                           
     data = 'Password';                          
     len = %len(%trimr(data));                   
     alg.HashAlg = HASH_SHA1;                    
     QDCXLATE(len: data: 'QTCPASC');             
     Qc3CalculateHash( %addr(data)               
                     : len                       
                     : 'DATA0100'                
                     : alg                       
                     : 'ALGD0500'                
                     : '0'                       
                     : *OMIT                     
                     : bin                   
                     : ErrorNull );              
     cvthc( hex: bin: %len(bin)*2);  
     dsply hex ;                             
     *inlr = *on;                                

User Comments

Please login or register to add comments

<Previous   Next>