Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Classic ASP Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
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)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

Create / Verify Digital Signature

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

This ASP script shows how to create and verify a digital signature using a certificate.

<html>
<head>
<title>ASP Digital Signature Example</title>
</head>
<body>
<%

' Get an object to create a certificate store object
set ccs = Server.CreateObject("Chilkat_9_5_0.CreateCS")

' Open the local machine certificate store.
set certStore = ccs.OpenLocalSystemStore()

' Find the certificate matching the email address "matt@chilkatsoft.com"
set cert = certStore.FindCertBySubjectE("matt@chilkatsoft.com")
	
' Create a Chilkat encryption instance to do the public-key encryption.
set crypt = Server.CreateObject("Chilkat_9_5_0.Crypt2")

' Use the digital certificate we obtained from the local machine store.
crypt.SetSigningCert cert

' Any value passed to UnlockComponent begins the 30-day trial.
unlocked = crypt.UnlockComponent("30-day trial")

stringToSign = "This is a test"

' Create a digital signature for the data.
' Return the signature as a hexidecimalized string.
crypt.EncodingMode = "hex"

signature = crypt.SignStringENC(stringToSign)

' Show the details of what happened during signing.
Response.write crypt.LastErrorHtml & "<br><br>"

' Show the signature
Response.write "Signature: " & signature & "<br><br>"

' Now check to see if the signature is valid.
' Use a different ChilkatCrypt2 object for demonstration purposes.
set crypt2 = Server.CreateObject("Chilkat_9_5_0.Crypt2")
crypt2.EncodingMode = "hex"
unaltered = crypt2.VerifyStringENC(stringToSign,signature)
if (unaltered = 1) then
	Response.write "1) The message has not been altered<br><br>"
else
	Response.write "1) The message has been altered!<br><br>"
end if

' Alter the message and check again.
alteredMessage = stringToSign & "."
unaltered = crypt2.VerifyStringENC(alteredMessage,signature)
if (unaltered = 1) then
	Response.write "2) The message has not been altered<br><br>"
else
	Response.write "2) The message has been altered!<br><br>"
end if

' Let's look at the cert that was used to sign...
set cert2 = crypt2.GetLastCert()
if not (cert2 is nothing) then

	' Which cert was it?
	Response.write "Certificate used: " & cert2.SubjectDN & "<br><br>"
	
	' Has the certificate been revoked?
	if cert2.Revoked then
		Response.write "This certificate has been revoked!<br><br>"
	end if
	
	' Has the certificate expired?
	if cert2.Expired then
		Response.write "This certificate has expired!<br><br>"
	end if
	
	' Is the certificate signature valid?
	if cert2.SignatureVerified = 0 then
		Response.write "This certificate does not have a valid signature!<br><br>"
	end if
	
	' Does the certificate have a trusted root?
	if cert2.TrustedRoot = 0 then
		Response.write "This certificate does not have a trusted root!<br><br>"
	end if
	
end if
		
%>
</body>
</html>
 

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