Sample code for 30+ languages & platforms
VBScript

Example: Crypt2.EncryptSb method

Demonstrates how to call the EncryptSb method.

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

set crypt = CreateObject("Chilkat.Crypt2")

set bdEncrypted = CreateObject("Chilkat.BinData")
set sbPlainText = CreateObject("Chilkat.StringBuilder")

success = sbPlainText.Append("Text to be encrypted")

' ...
' Set the secret key ...
' Set properties such as CryptAlgorithm, CipherMode, PaddingScheme, KeyLength
' Set the IV if needed ...
' ...

crypt.Charset = "utf-8"

success = crypt.EncryptSb(sbPlainText,bdEncrypted)
If (success = 0) Then
    outFile.WriteLine(crypt.LastErrorText)
    WScript.Quit
End If


outFile.Close