Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
Create Digital Signature for a File and Verify
VBScript to create a base-64 encoded digital signature for a file, and then verify it.
set crypt = CreateObject("Chilkat.Crypt2")
crypt.UnlockComponent "30-day trial"
crypt.EncodingMode = "Base64"
' We need a certificate for signing.
set createCs = CreateObject("Chilkat.CreateCS")
set certStore = createCs.OpenCurrentUserStore()
set cert = certStore.FindCertBySubject("fausey@chilkatsoft.com")
MsgBox crypt.LastErrorText
crypt.SetSigningCert cert
' The following block of code is only necessary if you want to control
' the signing algorithms.
set csp = CreateObject("Chilkat.Csp")
csp.SetProviderMicrosoftEnhanced
csp.SetHashAlgorithm "MD5"
crypt.SetCSP csp
' Create the detached signature
fileData = crypt.ReadFile("signFile.vbs")
signature = crypt.SignBytesENC(fileData)
MsgBox crypt.LastErrorText
crypt.WriteFile "base64sig.txt",signature
' Verify the signature.
sigData = crypt.ReadFile("base64sig.txt")
sigOK = crypt.VerifyBytesENC(fileData,sigData)
if sigOK = 1 then
MsgBox "signature is OK!"
else
MsgBox crypt.LastErrorText
end if
|
© 2000-2010 Chilkat Software, Inc. All Rights Reserved.