Visual Basic Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VB Examples

Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
Bzip2
PPMD
Deflate
LZW


VB Strings
VB Byte Array

 

 

 

 

 

 

 

TwoFish Encrypt to Match Counterpane Test Vectors (ECB Mode)

Download Chilkat Crypt ActiveX

Visual Basic 6.0 example showing how to encrypt using 128-bit TwoFish encryption to match a test vector published by Counterpane Systems, the inventor of Twofish.

'=========================
'
'FILENAME:  "ecb_vk.txt"
'
'Electronic Codebook (ECB) Mode
'Variable Key Known Answer Tests
'
'Algorithm Name:       TWOFISH
'Principal Submitter:  Bruce Schneier, Counterpane Systems
'
'==========
'
'KEYSIZE = 128
'
'PT=00000000000000000000000000000000
'I=1
'key=80000000000000000000000000000000
'CT=6BFD32804A1C3206C4BF85EB11241F89

Private Sub Command10_Click()

    Dim crypt As New ChilkatCrypt2
    crypt.UnlockComponent "30-day trial"
    
    Dim keyStr As String
    Dim clearStr As String
    
    keyStr1 = "80000000000000000000000000000000"
    clearStr1 = "00000000000000000000000000000000"
        
    Dim keyBytes As Variant
    Dim clearBytes As Variant
    
    ' Decode the hex strings to a Variant containing the bytes.
    crypt.CryptAlgorithm = "none"
    crypt.EncodingMode = "hex"
    keyBytes = crypt.DecryptBytesENC(keyStr1)
    clearBytes = crypt.DecryptBytesENC(clearStr1)
    
    crypt.CryptAlgorithm = "twofish"
    crypt.CipherMode = "ecb"
    crypt.KeyLength = 128
    crypt.SecretKey = keyBytes

    cipherStr = crypt.EncryptBytesENC(clearBytes)
    
    ' The Chilkat component pads to a multiple of 16 bytes.
    ' The default padding scheme is to pad with a byte value
    ' equaling the number of padding bytes.  If the input
    ' is an exact multiple of 16 bytes, as in this case,
    ' an extra 16 bytes of padding (padding byte = 0x10) is
    ' added.
    '
    ' Given that each byte is represented by 2 characters,
    ' we keep the 1st 32 characters of the output string
    ' to match the test vector exactly:
    cipherStr = Left$(cipherStr, 32)
    
    MsgBox cipherStr
    
End Sub

 

© 2000-2012 Chilkat Software, Inc. All Rights Reserved.