DataFlex
DataFlex
RSA Sign using Base64 Private Key
See more RSA Examples
Signs a string using a non-encrypted RSA private key in base64 encoding. Returns the RSA signature as a base64 string.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Variant vPrivKey
Handle hoPrivKey
Handle hoSbPem
Handle hoRsa
Variant vBd
Handle hoBd
String sStrOriginal
String sTemp1
Move False To iSuccess
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatPrivateKey)) To hoPrivKey
If (Not(IsComObjectCreated(hoPrivKey))) Begin
Send CreateComObject of hoPrivKey
End
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbPem
If (Not(IsComObjectCreated(hoSbPem))) Begin
Send CreateComObject of hoSbPem
End
Get ComAppendLine Of hoSbPem "-----BEGIN RSA PRIVATE KEY-----" True To iSuccess
Get ComAppendLine Of hoSbPem "MIIC .... j5A==" True To iSuccess
Get ComAppendLine Of hoSbPem "-----END RSA PRIVATE KEY-----" True To iSuccess
Get ComGetAsString Of hoSbPem To sTemp1
Get ComLoadPem Of hoPrivKey sTemp1 To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoPrivKey To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatRsa)) To hoRsa
If (Not(IsComObjectCreated(hoRsa))) Begin
Send CreateComObject of hoRsa
End
Get pvComObject of hoPrivKey to vPrivKey
Get ComUsePrivateKey Of hoRsa vPrivKey To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoRsa To sTemp1
Showln sTemp1
Procedure_Return
End
Get Create (RefClass(cComChilkatBinData)) To hoBd
If (Not(IsComObjectCreated(hoBd))) Begin
Send CreateComObject of hoBd
End
Get ComAppendString Of hoBd "12345678" "utf-8" To iSuccess
Get pvComObject of hoBd to vBd
Get ComSignRawBd Of hoRsa vBd To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoRsa To sTemp1
Showln sTemp1
Procedure_Return
End
// Get the base64 RSA signature.
Get ComGetEncoded Of hoBd "base64" To sTemp1
Showln sTemp1
Get pvComObject of hoBd to vBd
Get ComVerifyRawBd Of hoRsa vBd To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoRsa To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComGetString Of hoBd "utf-8" To sStrOriginal
Showln sStrOriginal
End_Procedure