C# Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

C# Examples

Bounced Mail
Character Encoding
Digital Certificates
Digital Signatures
Email
FTP
HTML to XML
HTTP
IMAP
Encryption
MHT / HTML Email
MIME
RSA Encryption
S/MIME
Socket
Spider
Tar Archive
Upload
XML
XMP
Zip Compression


More Examples...
Email Object
POP3
SMTP
RSS
Atom
String
Byte Array
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

ARC4 Encryption (ARCFOUR)

Download Chilkat .NET for 2.0 / 3.5 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

Demonstrates simple ARC4 encryption to match some simple test vectors published by Wikipedia. ARC4 is a fast stream cipher supporting key lengths from 8 to 2048 bits (i.e. from 1 to 256 bytes). It is not a block cipher, so there is no padding, no modes, and no initialization vector.

Download Chilkat .NET for 2.0 Framework

Download Chilkat .NET for 1.0 / 1.1 Framework

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

bool success;
success = crypt.UnlockComponent("Anything for 30-day trial");
if (success != true) {
    MessageBox.Show("Crypt component unlock failed");
    return;
}

//  Set the encryption algorithm to ARC4:
crypt.CryptAlgorithm = "arc4";

//  We want the encrypted output to be a hex-encoded string.
crypt.EncodingMode = "hex";

//  Encrypt some test vectors from Wikipedia:

string cipherText;
string plainText;

//  The key length (in bits) is equal to the number of us-ascii
//  bytes in our key string * 8.

// ARC4( "Key", "Plaintext" ) == BBF316E8D940AF0AD3
crypt.KeyLength = 24;
crypt.SetEncodedKey("Key","ascii");
cipherText = crypt.EncryptStringENC("Plaintext");
textBox1.Text += cipherText + "\r\n";
textBox1.Refresh();
plainText = crypt.DecryptStringENC(cipherText);
textBox1.Text += plainText + "\r\n";
textBox1.Refresh();

// ARC4( "Wiki", "pedia" ) == 1021BF0420
crypt.KeyLength = 32;
crypt.SetEncodedKey("Wiki","ascii");
cipherText = crypt.EncryptStringENC("pedia");
textBox1.Text += cipherText + "\r\n";
textBox1.Refresh();
plainText = crypt.DecryptStringENC(cipherText);
textBox1.Text += plainText + "\r\n";
textBox1.Refresh();

// ARC4( "Secret", "Attack at dawn" ) == 45A01F645FC35B383552544B9BF5
crypt.KeyLength = 48;
crypt.SetEncodedKey("Secret","ascii");
cipherText = crypt.EncryptStringENC("Attack at dawn");
textBox1.Text += cipherText + "\r\n";
textBox1.Refresh();
plainText = crypt.DecryptStringENC(cipherText);
textBox1.Text += plainText + "\r\n";
textBox1.Refresh();

//  Note: The call to SetEncodedKey serves to set the key
//  to the us-ascii bytes of the string.

 

Need a specific example? Send a request to support@chilkatsoft.com

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

Email Component · XML Parser