Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

Index of Chilkat Blog Posts

October 22, 2007

56-bit DES Encryption in C# (Using .NET Framework, not Chilkat)

This is a very simple example of encrypting a single 8-byte block of plaintext using the DES encryption algorithm (56-bit key, ECB mode). It does not use the Chilkat encryption component. The purpose of this example is to help in verifying the results of Chilkat’s DES encryption implementation, which is available in .NET, ActiveX, Perl, Ruby, Python, Java (for Windows), and C++ libs.

// 56-bit DES encrypt a single 8-byte block (ECB mode)
// plain-text should be 8-bytes, key should be 8 bytes.
public byte[] DesEncryptOneBlock(byte[] plainText, byte[] key)
    // Create a new DES key.
    DESCryptoServiceProvider des = new DESCryptoServiceProvider();
    // Set the KeySize = 64 for 56-bit DES encryption.
    // The msb of each byte is a parity bit, so the key length is actually 56 bits.
    des.KeySize = 64;
    des.Key = key;
    des.Mode = CipherMode.ECB;
    des.Padding = PaddingMode.None;
    ICryptoTransform ic = des.CreateEncryptor();
    byte[] enc = ic.TransformFinalBlock(plainText, 0,8);
    return enc;

Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.