C# Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

C# Examples

Bounced Mail
Bz2
Character Encoding
CSV
DKIM / DomainKey
Digital Certificates
Digital Signatures
Email
Email Object
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Amazon S3
NTLM
FileAccess
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

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.

Download Chilkat .NET for 4.0 Framework

Download Chilkat .NET for 64-bit 4.0 Framework (x64)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 64-bit 2.0 / 3.5 Framework (x64)

Download Chilkat .NET for 1.0 / 1.1 Framework

Chilkat.Crypt2 crypt = new Chilkat.Crypt2();

//  Any string argument automatically begins the 30-day trial.
bool success;
success = crypt.UnlockComponent("30-day trial");
if (success != true) {
    MessageBox.Show("Crypt component unlock failed");
    return;
}

Chilkat.Cert cert = new Chilkat.Cert();
success = cert.LoadByCommonName("Chilkat Software");
if (success != true) {
    MessageBox.Show(cert.LastErrorText);
    return;
}

//  Make sure this certificate has a private key available:
bool bHasPrivateKey;
bHasPrivateKey = cert.HasPrivateKey();
if (bHasPrivateKey != true) {
    MessageBox.Show("No private key available for signing.");
    return;
}

//  Tell the encryption component to use this cert.
crypt.SetSigningCert(cert);

string strData;
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.

string strSignatureWithData;
strSignatureWithData = crypt.OpaqueSignStringENC(strData);

textBox1.Text += strSignatureWithData + "\r\n";

//  Now verify the signature against the original data.

//  Tell the component what certificate to use for verification.
crypt.SetVerifyCert(cert);

string originalData;
originalData = crypt.OpaqueVerifyStringENC(strSignatureWithData);
if (originalData == null ) {
    //  The signature verification failed.
    MessageBox.Show(crypt.LastErrorText);
}
else {
    textBox1.Text += originalData + "\r\n";
    MessageBox.Show("Signature verified!");
}

 

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

Email Component · XML Parser