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
Sign a Byte Array to Create a Hex-Encoded SignatureDownload: Chilkat .NET Assemblies This example program signs an in-memory byte array and creates a hex encoded digital signature string. It also verifies the original byte data against the signature. ' This example uses the Chilkat .NET encryption library, which can be downloaded
' at http://www.chilkatsoft.com/downloads.asp
' Create an instance of the Chilkat encryption class.
Dim success As Boolean
Dim crypt As New Chilkat.Crypt2()
' Any code begins the 30-day trial.
crypt.UnlockComponent("30-day-trial")
' Load a certificate from a .cer file
' There are many other ways of loading a certificate...
Dim cert As New Chilkat.Cert()
success = cert.LoadFromFile("myCert.cer")
If (Not success) Then
MsgBox(cert.LastErrorText)
Exit Sub
End If
' Tell the crypt object to use the certificate.
crypt.SetSigningCert(cert)
' Tell the crypt object to hexidecimalize the resultant signature.
crypt.EncodingMode = "hex"
' File a byte array to sign
Dim inputData(10) As Byte
Dim i As Integer
For i = 1 To 10
inputData(i) = i
Next
' Sign the byte array.
Dim hexSignature As String
hexSignature = crypt.SignBytesENC(inputData)
If (hexSignature.Length = 0) Then
MsgBox(crypt.LastErrorText)
Exit Sub
End If
MsgBox("Digital signature created!")
' Now verify the signature.
Dim verified As Boolean
verified = crypt.VerifyBytesENC(inputData, hexSignature)
If Not verified Then
MsgBox(crypt.LastErrorText)
Else
MsgBox("Signature verified!")
End If
Important: The download for this
example does not contain the ChilkatDotNet.dll which |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.