1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| public DESedeEncrypt() {
byte[] buffer = new byte[] {
0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31,
0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31, 0x31
};
SecretKeySpec key = new SecretKeySpec(buffer, "DESede");
try {
encryptCipher = Cipher.getInstance(KEY_ALGORITHM);
encryptCipher.init(Cipher.ENCRYPT_MODE, key);
decryptCipher = Cipher.getInstance("DESede/ECB/NoPadding");
decryptCipher.init(Cipher.DECRYPT_MODE, key);
} catch (NoSuchAlgorithmException e) {
Throwables.propagate(e);
} catch (NoSuchPaddingException e) {
Throwables.propagate(e);
} catch (InvalidKeyException e) {
Throwables.propagate(e);
}
}
|