|
|
|
Как сделать Triple DES шифрацию с 112-битным ключов (двойным)
|
|||
|---|---|---|---|
|
#18+
Не могу понять, как добиться работы по алгоритмы Triple DES с двойным ключем (112-bit). То что делаю, требует 24-байтного ключа(156-bit). Применяю SDK 1.4.2 : SecretKeyFactory keyfactory = SecretKeyFactory.getInstance("TripleDES"); DESedeKeySpec keyspec = new DESedeKeySpec(data); SecretKey key = keyfactory.generateSecret(keyspec); byte[] encdata = encrypt(key, data); byte[] decdata = decrypt(key,encdata); --------- public static byte[] encrypt(SecretKey key, byte[] in) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException,IllegalBlockSizeException,BadPaddingException { Cipher cipher = Cipher.getInstance("DESede"); cipher.init(Cipher.ENCRYPT_MODE, key); return cipher.doFinal(in); } //------------------------------------------------------------------------------------------------------------- public static byte[] decrypt(SecretKey key, byte[] in) throws NoSuchAlgorithmException, InvalidKeyException, NoSuchPaddingException,IllegalBlockSizeException,BadPaddingException{ Cipher cipher = Cipher.getInstance("DESede"); cipher.init(Cipher.DECRYPT_MODE, key); return cipher.doFinal(in); } ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 12.09.2007, 08:48:37 |
|
||
|
|

start [/forum/topic.php?fid=59&tid=2144650]: |
0ms |
get settings: |
15ms |
get forum list: |
25ms |
check forum access: |
6ms |
check topic access: |
6ms |
track hit: |
45ms |
get topic data: |
21ms |
get forum data: |
5ms |
get page messages: |
47ms |
get tp. blocked users: |
3ms |
| others: | 361ms |
| total: | 534ms |

| 0 / 0 |
