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

 

 

 

 

 

 

 

Opaque Digital Signature Embedding

Download Chilkat Crypt ActiveX

Create an opaque digital signature that embeds the original file data along with the signature. Then verify and extract the original data.

    Dim crypt As New ChilkatCrypt2
    crypt.UnlockComponent "test"

    ' Select a digital certificate for signing.
    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()
    
    ' Find a certificate matching an email address.
    Dim cert As ChilkatCert
    Set cert = certStore.FindCertBySubjectE("test@chilkatsoft.com")
    If (cert Is Nothing) Then
        MsgBox "Certificate not found!"
        Exit Sub
    End If
        
    ' Use this certificate.
    crypt.SetSigningCert cert
    
    Dim fileData As Variant
    Dim opaqueSig As Variant
    
    fileData = crypt.ReadFile("sample.pdf")
    If IsNull(fileData) Then
        MsgBox crypt.LastErrorText
        Exit Sub
    End If
    
    opaqueSig = crypt.OpaqueSignBytes(fileData)
    If IsNull(opaqueSig) Then
        MsgBox crypt.LastErrorText
        Exit Sub
    End If
    
    ' opaqueSig.dat contains both the file data and the signature.
    success = crypt.WriteFile("opaqueSig.dat", opaqueSig)
    If (success = 0) Then
        MsgBox crypt.LastErrorText
    End If
    
    MsgBox "OK!"
    
    ' Now verify it and retrieve the original file from opaqueSig.dat
    Dim opaqueSig2 As Variant
    
    opaqueSig2 = crypt.ReadFile("opaqueSig.dat")
    If IsNull(opaqueSig2) Then
        MsgBox crypt.LastErrorText
        Exit Sub
    End If
    
    Dim originalData As Variant
    originalData = crypt.OpaqueVerifyBytes(opaqueSig2)
    If IsNull(originalData) Then
        MsgBox "Invalid signature, the file may have been altered."
    Else
        crypt.WriteFile "sampleOut.pdf", originalData
        MsgBox "Signature is valid, the file is unchanged."
    End If

 

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