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 / Verify Digital Signature for a PDF

Download Visual Basic Project Files and Source Code

Demonstrates how to create a detached digital signature for a PDF or any type of file.

' Creates a signature file for a PDF, and then loads the signature
' and verifies that the PDF has not been altered.
' Uses: ChilkatCrypt.dll, ChilkatCert.dll, ChilkatUtil.dll
Private Sub Command1_Click()

    Dim crypt As New ChilkatCrypt
    crypt.UnlockComponent "UnlockCode"
    
    ' Specify a string for locating the digital certificate within
    ' the well-known certificate stores.
    ' Chilkat Crypt will automatically find the certificate that
    ' matches.
    crypt.SigningCertSubject = "matt@chilkatsoft.com"
    
    ' Another way of telling Chilkat Crypt which certificate to use
    ' is to load a .cer or .p7b file...
    'Dim cert As New ChilkatCert
    'cert.LoadFromFile "myCert.cer"
    'crypt.SetSigningCertificate cert
    
    ' Create a digital signature for a PDF, and save it to a file.
    Dim sigData As CkData
    Set sigData = crypt.CreateSigFile2Obj("sample.pdf")
    fileSaved = sigData.SaveToFile("sig.dat")
    If (fileSaved = 0) Then
        MsgBox sigData.ErrorLogText
    End If
    
    ' Load the digital signature and verify that the PDF has not changed.
    Set sigData = New CkData
    fileLoaded = sigData.LoadFile("sig.dat")
    If (fileLoaded = 0) Then
        MsgBox sigData.ErrorLogText
    End If
    
    sigValid = crypt.VerifySigFile2Obj("sample.pdf", sigData)
    If (sigValid = 1) Then
        MsgBox "PDF is unaltered!" & vbCrLf & crypt.LastCertSubject
    Else
        MsgBox "PDF has been altered!"
    End If
    
End Sub

 

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

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