import javax.crypto.spec.*; import javax.crypto.Cipher; public class lmhash { public static void main(String[] args) throws Exception { byte[] raw = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; Parity p = new Parity(); byte[] pkey = p.addParity(raw); SecretKeySpec key = new SecretKeySpec(pkey, "DES"); Cipher ecipher = Cipher.getInstance("DES"); ecipher.init(Cipher.ENCRYPT_MODE, key); byte[] plainText = "KGS!@#$%".getBytes(); byte[] crypted = ecipher.doFinal(plainText); String[] h_hex = new String[8]; h_hex = (Integer.toHexString(crypted & 0xFF)); for(int x = 0;x <= 7;x++) { System.out.print(Integer.toHexString(crypted[x] & 0xFF)); h_hex[x] = (char) (Integer.toHexString(crypted[x] & 0xFF)); } } }