(VB.NET) 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 Chilkat.PrivateKey
Dim success As Boolean
Dim sbPem As New Chilkat.StringBuilder
sbPem.AppendLine("-----BEGIN RSA PRIVATE KEY-----",True)
sbPem.AppendLine("MIIC .... j5A==",True)
sbPem.AppendLine("-----END RSA PRIVATE KEY-----",True)
success = privKey.LoadPem(sbPem.GetAsString())
If (success <> True) Then
Debug.WriteLine(privKey.LastErrorText)
Exit Sub
End If
Dim rsa As New Chilkat.Rsa
success = rsa.ImportPrivateKeyObj(privKey)
If (success <> True) Then
Debug.WriteLine(rsa.LastErrorText)
Exit Sub
End If
rsa.EncodingMode = "base64"
Dim strSigned As String = rsa.OpenSslSignStringENC("12345678")
Debug.WriteLine(strSigned)
Dim strOriginal As String = rsa.OpenSslVerifyStringENC(strSigned)
Debug.WriteLine(strOriginal)
|