Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python 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("ChilkatCrypt2.ChilkatCrypt2")
crypt.UnlockComponent "30-day trial"
crypt.EncodingMode = "Base64"
' We need a certificate for signing.
set createCs = CreateObject("ChilkatCertificate.ChilkatCreateCS")
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("ChilkatUtil.ChilkatCSP")
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
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2003-2007 Chilkat Software, Inc. All Rights Reserved.