(VBScript) RSA Import Private Key
Shows how to select/import a private key for RSA signing or decryption.Note: This example requires Chilkat v11.0.0 or greater.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
set privKey = CreateObject("Chilkat.PrivateKey")
password = "secret"
' In all Chilkat methods expecting a path, you pass either absolute or relative paths.
success = privKey.LoadAnyFormatFile("rsaKeys/myTestRsaPrivate.pem",password)
If (success = 0) Then
outFile.WriteLine(privKey.LastErrorText)
WScript.Quit
End If
set rsa = CreateObject("Chilkat.Rsa")
' Tell the RSA object to use the private key (i.e. import the private key)
success = rsa.UsePrivateKey(privKey)
outFile.Close
|