Chilkat HOME Android™ ASP Visual Basic VB.NET C# iOS (IPhone) Objective-C C++ C Unicode C++ Unicode C MFC Delphi DLL Delphi ActiveX FoxPro Java Perl PHP Extension PHP ActiveX Python PowerShell Ruby SQL Server VBScript
Encrypt ANSI / Unicode StringsDownload: Chilkat .NET Assemblies This example demonstrates two ways to encrypt strings. The first encrypts a a Unicode string (2 bytes per character) while the second encrypts ANSI string (1 byte per character) . NOTE: This example uses the Chilkat.Crypt class, not Chilkat.Crypt2 private void button2_Click(object sender, System.EventArgs e)
{
// Setup the encryption object for 128-bit AES encryption.
Chilkat.Crypt crypt = new Chilkat.Crypt();
crypt.UnlockComponent("UnlockCode");
crypt.SetAlgorithmRijndael();
crypt.KeyLength = 128;
crypt.SetSecretKeyViaPassPhrase("myPassword");
// Encrypt Unicode characters (2 bytes per character)
System.Text.UnicodeEncoding enc = new System.Text.UnicodeEncoding();
byte [] dBytes = enc.GetBytes("This is a test");
byte [] encryptedBytes = crypt.Encrypt(dBytes);
textBox1.Text = crypt.EncodeBase64(encryptedBytes);
// Encrypt an ANSI string (1 byte per character)
textBox2.Text = crypt.EncodeBase64(crypt.EncryptStr("This is a test"));
}
|
© 2000-2013 Chilkat Software, Inc. All Rights Reserved.