Visual Basic Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



VB Examples

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

More Examples...
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor


VB Strings
VB Byte Array

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

 

 

 

 

 

 

 

Create and Verify Opaque Digital Signatures

Demonstrates how to sign a file using a digital certificate. Then loads the opaque signed file, verifies the signature and recovers the original file data and the certificate used for signing.

    ' Add references to both Chilkat Crypt and Chilkat Certificate.
    
    ' Digitally sign a file, then verify the signature and
    ' fetch the certificate used for signing.
    Dim crypt As New ChilkatCrypt2
    crypt.UnlockComponent "anything for 30-day trial"
    
    ' Get a certificate for signing.
    Dim ccs As New ChilkatCreateCS
    Dim certStore As ChilkatCertStore
    Dim cert As ChilkatCert
    
    ' For the purpose of simplifying the example, we do not
    ' check for errors.  To check for errors, make sure the object
    ' reference returned is not Nothing.
    Set certStore = ccs.OpenLocalSystemStore()
    Set cert = certStore.FindCertBySubjectE("admin@tagtooga.com")
    
    Dim fileData As Variant
    fileData = crypt.ReadFile("hamlet.xml")
    
    Dim signedFileData As Variant
    crypt.SetSigningCert cert
    signedFileData = crypt.OpaqueSignBytes(fileData)
    
    crypt.WriteFile "hamletSigned.xml.sgn", signedFileData
    
    
    ' Now load the file and verify the signature, recovering the original
    ' file contents and getting the cert used for signing.
    Dim crypt2 As New ChilkatCrypt2
    
    Dim inData As Variant
    inData = crypt2.ReadFile("hamletSigned.xml.sgn")
    
    Dim outData As Variant
    outData = crypt2.OpaqueVerifyBytes(inData)
    If (IsNull(outData)) Then
        MsgBox crypt2.LastErrorText
    Else
        ' Get the certificate used to sign..
        Dim sigCert As ChilkatCert
        Set sigCert = crypt2.GetLastCert()
        
        ' Save the output:
        crypt2.WriteFile "hamletOriginal.xml", outData
        
        MsgBox "Success: " + cert.SubjectDN
    End If

 

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

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