VB.NET Examples

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

VB.NET Examples

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

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

Byte Array
VB.NET FTPS
System.IO

 

 

 

 

 

 

ASCII / ANSI Secret Key in Symmetric Encryption

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

Using an ASCII (or ANSI) secret key w/ symmetric encryption: AES, Blowfish, Twofish, RC2, 3DES, etc.

Dim crypt As New Chilkat.Crypt2()

Dim success As Boolean
success = crypt.UnlockComponent("Anything for 30-day trial")
If (success <> true) Then
    MsgBox("Crypt component unlock failed")
    Exit Sub
End If


'  A frequent support question goes something like this:
'  ------------------
'  I am not able to decrypt strings encrypted using
'  cryptix.jce.provider.key.RawSecretKey (Java) like I would normally do.

' The key generation is being done with the Rijndael algorithm (256-bit)
'  The AES encryption algorithm is "Rijndael/ECB/PKCS#5"

'  The 32 character source key I'm using is this:
'  1234567890123456789012345678912
' 
'  ------------------
'  The customer tries to call GenerateSecretKey to
'  convert the 32-character source key to a binary secret key,
'  but this is incorrect (in this case).  GenerateSecretKey
'  hashes a string of any length and produces binary hash output
'  that is of the appropriate size to be used as a secret key.

'  The telltale sign is that in this case, the string is the exact
'  length of the secret key.  32 ANSI characters = 256 bits.
'  Therefore, it is obvious that the bytes of the binary
'  secret key should be the exact ascii character values
'  of the string.

Dim encKey As String
encKey = "1234567890123456789012345678912"

crypt.CryptAlgorithm = "aes"
'  Mode is "ecb" or "cbc"
crypt.CipherMode = "ecb"
crypt.KeyLength = 256

'  Call SetEncodedKey with "ascii" to tell the component
'  to use the ascii-bytes as the binary secret key.
'  Make sure you call this after setting the KeyLength.
crypt.SetEncodedKey(encKey,"ascii")

crypt.EncodingMode = "base64"
Dim text As String
text = "The quick brown fox jumped over the lazy dog."

'  Encrypt a string and return the binary encrypted data
'  in a base-64 encoded string.
Dim encText As String
encText = crypt.EncryptStringENC(text)

TextBox1.Text = TextBox1.Text & encText & vbCrLf

'  Decrypt and show the original string:
Dim decryptedText As String
decryptedText = crypt.DecryptStringENC(encText)

TextBox1.Text = TextBox1.Text & decryptedText & vbCrLf
 

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

Mail Component · XML Parser