Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Create / Verify Digital Signature for a PDF 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.