Listing 1: Hashing with the Microsoft Crypto API

blob     lblb_Hash
ulong     lul_Hash, lul_Len, lul_Ret, lul_Crypto
string     ls_Null

SetNull( ls_Null)
IF CryptAcquireContext( lul_Crypto, ls_Null, &
    ls_Null, PROV_RSA_FULL, 0) THEN
    lul_Len = 20 // Size of SHA-1
    lblb_Hash = Blob( Space( lul_Len ) )
    // Create SHA-1 Hash Object
    IF CryptCreateHash( lul_Crypto, CALG_SHA1, 0, &
      0, lul_Hash ) THEN
      // Generate Hash, ablb_Data is argument
      IF CryptHashData( lul_Hash, ablb_Data, &
       Len( ablb_Data ), 0 ) THEN
       // Retrieve Hash Data
       IF CryptGetHashParam( lul_Hash, &
     HP_HASHVAL, lblb_Hash, lul_Len, 0) THEN
     // The hash is in the lblb_Hash blob -> Do further processing here
     ELSE
       lul_Ret = GetLastError()
     END IF
    ELSE
     lul_Ret = GetLastError()
    END IF
    // Clean up
    CryptDestroyHash( lul_Hash )
   ELSE
    lul_Ret = GetLastError()
   END IF
   CryptReleaseContext( lul_Crypto, 0)
END IF

Listing 2: Hashing with the PowerBuilder Crypto Library

n_cst_cryptography lnv_Crypto
PBCrypto pbcrypto
string ls_Message, ls_Result

TRY
   IF lnv_Crypto.of_GetInstance(pbcrypto) THEN
    ls_Result = pbcrypto.GenerateMessageDigest( &
     "SHA-1", ls_Message)
   END IF
CATCH (NoSuchAlgorithmException nsae)
   MessageBox("Alert", nsae.getMessage())
END TRY