(VBScript) Get Base64 Public Key from Private Key
Demonstrates how to get the public key in base64 format from a private key.
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
' Load a private key from base64.
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.BinData")
set bd = CreateObject("Chilkat.BinData")
success = bd.AppendEncoded("MHQCA....n0Q==","base64")
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.PrivateKey")
set privKey = CreateObject("Chilkat.PrivateKey")
success = privKey.LoadAnyFormat(bd,"")
If (success = 0) Then
outFile.WriteLine(privKey.LastErrorText)
WScript.Quit
End If
' pubKey is a Chilkat.PublicKey
Set pubKey = privKey.GetPublicKey()
If (privKey.LastMethodSuccess = 0) Then
outFile.WriteLine(privKey.LastErrorText)
WScript.Quit
End If
pubKeyBase64 = pubKey.GetEncoded(1,"base64")
outFile.WriteLine(pubKeyBase64)
outFile.Close
|