Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Classic ASP Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(Classic ASP) Extract PKCS7 Signature Digest

Demonstrates how to extract a signature digest from a PKCS7 signature.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
'  This example requires the Chilkat Crypt API to have been previously unlocked.
'  See Unlock Chilkat Crypt for sample code.

set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2")

p7mFile = "qa_data/p7m/test.pdf.p7m"
outPath = "qa_output/test.pdf"

'  First let's see if this .p7m signature can be verified, and the original file extracted.
verified = crypt.VerifyP7M(p7mFile,outPath)
If (verified <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( crypt.LastErrorText) & "</pre>"
    Response.End
End If

'  How many signers?
'  (The NumSignerCerts property is set whenever a signature is verified.)
Response.Write "<pre>" & Server.HTMLEncode( "Num Signers: " & crypt.NumSignerCerts) & "</pre>"

'  Load the .p7m into memory...
set pkcs7Data = Server.CreateObject("Chilkat_9_5_0.BinData")
success = pkcs7Data.LoadFile(p7mFile)

'  Check to see if this .p7m contains the binary bytes, or if it's
'  already base64 encoded.  Get the 1st two bytes.  If the first two
'  bytes are the us-ascii values "MI", then we have base64.
set sbBase64 = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
hexStr = pkcs7Data.GetEncodedChunk(0,2,"hex")
success = sbBase64.Append(hexStr)

bHaveBase64 = 0
If (sbBase64.ContentsEqual("4D49",1) = 1) Then
    bHaveBase64 = 1
    sbBase64.Clear 
    success = sbBase64.AppendBd(pkcs7Data,"utf-8",0,0)
End If

'  Get each signer's signature digest.
crypt.EncodingMode = "base64"
i = 0

Do While i < crypt.NumSignerCerts
    If (bHaveBase64) Then
        digest = crypt.Pkcs7ExtractDigest(i,sbBase64.GetAsString())
    Else
        digest = crypt.Pkcs7ExtractDigest(i,pkcs7Data.GetEncoded("base64"))
    End If

    If (crypt.LastMethodSuccess <> 1) Then
        Response.Write "<pre>" & Server.HTMLEncode( crypt.LastErrorText) & "</pre>"
        Response.End
    End If

    Response.Write "<pre>" & Server.HTMLEncode( "Signer " & i + 1 & " digest = " & digest) & "</pre>"
    i = i + 1
Loop

%>
</body>
</html>

 

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