VBScript Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



VBScript Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
PFX
RSA Encryption
S/MIME
Socket
Spider
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Email Object
POP3
SMTP
Byte Array
RSS
Atom

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

Blowfish Encryption in VBScript

Demonstrates string-to-string blowfish encryption in VBScript

'**********************************************************
'** Blowfish String Encryption in VbScript
'**********************************************************

set blowfish = CreateObject("ChilkatCrypt2.ChilkatCrypt2")
blowfish.UnlockComponent("Anything for 30-day trial")

' Set the encryption algorithm to blowfish.
' Use "blowfish2" to enable cipher-block chaining (CBC) to be used.
blowfish.CryptAlgorithm = "blowfish2"

' Set the cipher mode to cbc (this is the default).  The other cipher mode is "ecb".
blowfish.CipherMode = "cbc"

' The key length can be anything from 64 bits to 448 bits
blowfish.KeyLength = 256
    
' Padding Schemes:
' 0((RFC2630) Each padding byte is the pad count (16 extra added if size is already a multiple of 16)
' 1(Random bytes except the last is the pad count (16 extra added if size is already multiple of 16)
' 2(Pad with random data. (If already a multiple of 16, no padding is added).
' 3(Pad with NULLs. (If already a multiple of 16, no padding is added).
' 4(Pad with SPACE chars(0x20). (If already a multiple of 16, no padding is added).
blowfish.PaddingScheme = 4
    
' Set the 8-byte initialization vector via a hex encoded string.
' Blowfish is a 64-bit block cipher, so the IV is always 64 bits.
blowfish.SetEncodedIV "0001020304050607", "hex"
    
' Set our secret key.  To do this, we hash a password string to a binary secret key
' having the correct bit length (equal to the key length).
keyBytes = blowfish.GenerateSecretKey("secret_password")
blowfish.SecretKey = keyBytes
    
' Encrypt a string, returning the encrypted data as a hex encoded string.
blowfish.EncodingMode = "hex"

cipherText = blowfish.EncryptStringENC("ABCDEFGHIJKLMNOPQRSTUVWXYZ")

' The blowfish algorithm pads to a 16-byte multiple.  In this example, the 26-byte
' input string is padded to 32 bytes with SPACE characters and encrypted.
' The result is a 64-byte hex string (2 characters per binary byte)
MsgBox len(cipherText)
MsgBox cipherText

' Decrypting is easy...
clearText = blowfish.DecryptStringENC(cipherText)

' The decrypted string will contain the padding, so it needs to be trimmed.
MsgBox Trim(clearText)

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2003-2007 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser