Encrypting/decrypting a message using a symmetric encryption method (eg. DES)

Eric Young has written an implementation of DES. Here are the source files:

Des.java
DesCrypt.java
DesKey.java
Int32Manipulator.java

The Des.java file has been slightly modified (added a memset method to ensure 8 bytes are used for the key).

Here’s an example on how to use these classes:

public class Main
{
   public static void main(String []args) {
      // key (8 bytes) 
      String key = "12345678";
 
      // encrypt using Eric Young's DES Java implementation
      byte[] de = Des.encrypt(key, "Esus.com, aiming to provide the largest Java directory on the web");
 
      // decrypt 
      String s = Des.decrypt(key, de);
      System.out.println(s);
   }
}