3DES
默认为ECB加密, JAVA中该算法名为 DESede,每次加密8字节
try { String password = "123456780000111122223333"; byte[] b = password.getBytes(); // 必须是>=24字节的数组,否则返回InvalidKeyException DESedeKeySpec dks = new DESedeKeySpec(b); SecretKeyFactory keyFactory = SecretKeyFactory.getInstance( "DESede" ); SecretKey key = keyFactory.generateSecret( dks ); Cipher cipher = Cipher.getInstance("DESede"); cipher.init(Cipher.ENCRYPT_MODE, key); String plain = "shaofa00"; byte [] input = plain.getBytes(); byte [] output = cipher.update(plain.getBytes()); System.out.println("haha"); } catch(Exception e) { e.printStackTrace(); }
加密后的数据
50 F1 30 74 9B 20 32 60
-102 -17 14 -41 38 -88 90 -19