![]() |
Chilkat HOME Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi DLL Go Java Node.js Objective-C PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
PKCS7 SignedData Signature (embeds Signed Data)How to create a PKCS7 signature. The resulting PKCS7 structure is encoded to a printable string using hex or base64 encoding. The data being signed is embedded within the PKCS#7 structure. Demonstrates how to verify the signature and recover the original data.
<html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2") ' Any string argument automatically begins the 30-day trial. success = crypt.UnlockComponent("30-day trial") If (success <> 1) Then Response.Write "Crypt component unlock failed" & "<br>" End If set cert = Server.CreateObject("Chilkat_9_5_0.Cert") success = cert.LoadByCommonName("Chilkat Software") If (success <> 1) Then Response.Write cert.LastErrorText & "<br>" End If ' Make sure this certificate has a private key available: bHasPrivateKey = cert.HasPrivateKey() If (bHasPrivateKey <> 1) Then Response.Write "No private key available for signing." & "<br>" End If ' Tell the encryption component to use this cert. crypt.SetSigningCert cert strData = "This is the data to be signed." ' Indicate that the PKCS7 signature should be returned ' as a base64 encoded string: crypt.EncodingMode = "base64" ' The EncodingMode may be set to other values such as ' "hex", "url", "quoted-printable", etc. strSignatureWithData = crypt.OpaqueSignStringENC(strData) Response.Write Server.HTMLEncode( strSignatureWithData) & "<br>" ' Now verify the signature against the original data. ' Tell the component what certificate to use for verification. crypt.SetVerifyCert cert originalData = crypt.OpaqueVerifyStringENC(strSignatureWithData) If (originalData = vbNullString ) Then ' The signature verification failed. Response.Write crypt.LastErrorText & "<br>" Else Response.Write Server.HTMLEncode( originalData) & "<br>" Response.Write "Signature verified!" & "<br>" End If %> </body> </html> |
||||
© 2000-2026 Chilkat Software, Inc. All Rights Reserved.