Sample code for 30+ languages & platforms
VBScript

Use Base64 RSA Key to Encrypt

See more RSA Examples

Loads a Base64 RSA key and uses it to encrypt a string, returning the result in base64.

Chilkat VBScript Downloads

VBScript
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

' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

set pubkey = CreateObject("Chilkat.PublicKey")

success = pubkey.LoadBase64("MIICdgIBADA ... A9PXLk+j5A==")
If (success = 0) Then
    outFile.WriteLine(pubkey.LastErrorText)
    WScript.Quit
End If

set rsa = CreateObject("Chilkat.Rsa")

success = rsa.UsePublicKey(pubkey)
If (success = 0) Then
    outFile.WriteLine(rsa.LastErrorText)
    WScript.Quit
End If

rsa.EncodingMode = "base64"

encryptedStr = rsa.EncryptStringENC("12345678",0)

outFile.WriteLine(encryptedStr)

outFile.Close