IBM Support

Example of ILE RPG Program Calling the Qc3CalculateHash API

Troubleshooting


Problem

This document provides an example of the cryptographic API, Qc3CalculateHash, in RPG.

Resolving The Problem

Caution: This document is only an example. IBM accepts no responsibility for its correctness.


The following is an example of an ILE RPG program that calls the Qc3CalculateHash API.

Example

D/COPY QSYSINC/QRPGLESRC,QC3CCI                                    
Dhash             pr                  extproc('Qc3CalculateHash')  
D                               20a   options(*varsize)            
D                                9B 0                              
D                                8A                                
D                               20a   options(*varsize)            
D                                8A                                
D                                1A                                
D                               10A                                
D                               20A   OPTIONS(*VARSIZE)            
D                              300A   OPTIONS(*VARSIZE)            
 * variables *                                                    
 *************                                                    
Dinputdta         S             20A                                
Dinputlen         S              9B 0                              
Dinputfmt         S              8A   inz('DATA0100')              
DAlgDesc          S             20a   inz('2')                    
DAlgDescFmt       S              8a   INZ('ALGD0500')              
DCryptoServ       S              1A   inz('0')                    
DCryptoDev        S             10A   inz(*BLANKS)            
DHashout          S             20A                            
 *                                                            
D ErrorCD         DS                                          
D  BytesProv                    10I 0 inz(%size(ErrorCD))      
D BytesAvail                    10I 0                          
D MsgId                          7A                            
D  Reserved                      1A                            
D  MsgReplacementText...                                      
D                              300A                            
D                                                                      
D@CVV2            S             20A                                    
C                                                                      
C                   eval      inputdta = '123'                        
C                   eval      inputlen = %len(%trim(inputdta))        
C                   eval      QC3HA = 2                                
C                   callp     hash(inputdta:inputlen:inputfmt:        
C                             QC3D0500:algdescfmt:cryptoserv:          
C                             cryptoDev:hashout:errorCD)              
C                                                                      
C                   eval      @cvv2 = hashout              
c                   dsply                   @CVV2          
C*                                                        
C                   eval      *inlr = *on                

Note: You may need to take %trim out of the code for the reason spaces are valid data for ciphertext.
[{"Type":"MASTER","Line of Business":{"code":"LOB57","label":"Power"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SWG60","label":"IBM i"},"Platform":[{"code":"PF012","label":"IBM i"}],"Version":"6.1.0"}]

Historical Number

468771572

Document Information

More support for:
IBM i

Software version:
6.1.0

Operating system(s):
IBM i

Document number:
636149

Modified date:
11 November 2019

UID

nas8N1014013

Manage My Notification Subscriptions