(Visual Basic 6.0) RSA Sign using Base64 Private Key
Signs a string using a non-encrypted RSA private key in base64 encoding. Returns the RSA signature as a base64 string.
' This requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.
Dim privKey As New PrivateKey
Dim success As Long
Dim sbPem As New ChilkatStringBuilder
success = sbPem.AppendLine("-----BEGIN RSA PRIVATE KEY-----",1)
success = sbPem.AppendLine("MIIC .... j5A==",1)
success = sbPem.AppendLine("-----END RSA PRIVATE KEY-----",1)
success = privKey.LoadPem(sbPem.GetAsString())
If (success <> 1) Then
Debug.Print privKey.LastErrorText
Exit Sub
End If
Dim rsa As New ChilkatRsa
success = rsa.ImportPrivateKeyObj(privKey)
If (success <> 1) Then
Debug.Print rsa.LastErrorText
Exit Sub
End If
rsa.EncodingMode = "base64"
Dim strSigned As String
strSigned = rsa.OpenSslSignStringENC("12345678")
Debug.Print strSigned
Dim strOriginal As String
strOriginal = rsa.OpenSslVerifyStringENC(strSigned)
Debug.Print strOriginal
|