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

 

 

 

 

 

 

 

Public-Key Encrypt Text in a TextBox

Download Chilkat Crypt ActiveX

RSA encryption and decryption of text in Visual Basic. Also does Base64 encoding/decoding and BZip2 compression/decompression.

Private Sub Encrypt_Click()

    Dim crypt As New ChilkatCrypt2

    ' Load a digital certificate.
    ' You only need the public key to encrypt.
    ' The private key will be needed to decrypt,
    ' so your own certificate needs to be used.
    Dim cert As New ChilkatCert
    cert.LoadFromFile "matt.cer"
    
    ' Anything starts the 30-day trial
    crypt.UnlockComponent "30DayTrial"
    
    crypt.SetEncryptCert cert
    
    ' Setup the encryption parameters
    ' Compress the data before encrypting.
    crypt.CompressionAlgorithm = "BZIP2"
    ' Use public-key encryption (as opposed to password-based symmetric encryption)
    crypt.CryptAlgorithm = "PKI"
    ' Return the encrypted data as a Base64-encoded string.
    crypt.EncodingMode = "BASE64"
    ' VB uses Unicode, so convert to ANSI (1 byte per char) before encrypting.
    crypt.Charset = "ANSI"
    
    Text2.Text = crypt.EncryptStringENC(Text1.Text)
    Text1.Text = "OK, now press Decrypt"
        
End Sub

Private Sub Decrypt_Click()

    Dim crypt As New ChilkatCrypt2

    ' Anything starts the 30-day trial
    crypt.UnlockComponent "30DayTrial"
    
    ' Setup the encryption parameters
    ' After decrypting, decompress the data.
    crypt.CompressionAlgorithm = "BZIP2"
    ' Use public-key encryption (as opposed to password-based symmetric encryption)
    crypt.CryptAlgorithm = "PKI"
    ' Indicate that the data to be decrypted is base-64 encoded.
    crypt.EncodingMode = "BASE64"
    ' VB uses Unicode, so convert from ANSI to Unicode after decrypting.
    crypt.Charset = "ANSI"
    
    Text1.Text = crypt.DecryptStringENC(Text2.Text)
    If (Len(Text1.Text) = 0) Then
        MsgBox crypt.LastErrorText
    End If
    Text3.Text = "There you go!"

End Sub



Private Sub Form_Load()

    ' Load the text box with some data.
    Text1.Text = ""
    For i = 1 To 300
        Text1.Text = Text1.Text & Str(i) & " abcd 1234 zzzzzzzzzzzzz aaaaaaaaaaaa" & vbCrLf
    Next
    

End Sub


 

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