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

 

 

 

 

 

 

 

String-to-String Public-Key Encryption / Decryption

Download Chilkat Crypt ActiveX

Demonstrates how to use Chilkat Crypt for string-to-string public-key encryption and decryption.


Private Sub Command1_Click()
    ' String to string public-key encryption / decryption using digital certificates.
    Dim crypt As New ChilkatCrypt2
    crypt.UnlockComponent UnlockCode.Text
    
    ' Locate a certificate using Chilkat Cert
    Dim StoreCreator As New ChilkatCreateCS
    Dim certStore As ChilkatCertStore
    Set certStore = StoreCreator.OpenCurrentUserStore()
    If (certStore Is Nothing) Then
        MsgBox StoreCreator.LastErrorText
        Exit Sub
    End If
    Dim cert As ChilkatCert
    Set cert = certStore.FindCertBySubject(CertSubject.Text)
    If (cert Is Nothing) Then
        MsgBox certStore.LastErrorText
        Exit Sub
    End If
    
    ' Encrypt and decrypt...
    crypt.EncodingMode = "Base64"
    crypt.CryptAlgorithm = "PKI"
    
    crypt.SetEncryptCert cert 

    Text2.Text = crypt.EncryptStringENC(Text1.Text)
    If (Len(Text2.Text) = 0) Then
        MsgBox crypt.LastErrorText
        Exit Sub
    End If
    Text3.Text = crypt.DecryptStringENC(Text2.Text)
    If (Len(Text3.Text) = 0) Then
        MsgBox crypt.LastErrorText
        Exit Sub
    End If
    
End Sub

Private Sub Form_Load()

    ' Create our certificate store factory object.
    Dim StoreCreator As ChilkatCreateCS
    Set StoreCreator = New ChilkatCreateCS
    
    ' Create a certificate store object representing the registry-based
    ' current user certificate store.
    Dim certStore As ChilkatCertStore
    Set certStore = StoreCreator.OpenCurrentUserStore()
    
    ' Get the number of certificates in the store.
    NumCerts = certStore.NumCertificates
    Dim cert As ChilkatCert
    
    ' Loop over the certificates, get each certificate and print information about each.
    For Index = 0 To NumCerts - 1
        Set cert = certStore.GetCertificate(Index)
        List1.AddItem cert.SubjectCN + ", " + cert.SubjectE
    Next
    Set certStore = Nothing


    Set certStore = StoreCreator.OpenLocalSystemStore()
    
    ' Get the number of certificates in the store.
    NumCerts = certStore.NumCertificates
    
    ' Loop over the certificates, get each certificate and print information about each.
    For Index = 0 To NumCerts - 1
        Set cert = certStore.GetCertificate(Index)
        List2.AddItem cert.SubjectCN + ", " + cert.SubjectE
    Next
    Set certStore = Nothing


    Set certStore = StoreCreator.OpenOutlookStore()
    
    ' Get the number of certificates in the store.
    NumCerts = certStore.NumCertificates
    
    ' Loop over the certificates, get each certificate and print information about each.
    For Index = 0 To NumCerts - 1
        Set cert = certStore.GetCertificate(Index)
        List3.AddItem cert.SubjectCN + ", " + cert.SubjectE
    Next
    Set certStore = Nothing


End Sub


 

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