|
|
|
Как сделать 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&fpage=611&tid=2144650]: |
0ms |
get settings: |
15ms |
get forum list: |
27ms |
check forum access: |
8ms |
check topic access: |
8ms |
track hit: |
63ms |
get topic data: |
24ms |
get forum data: |
7ms |
get page messages: |
59ms |
get tp. blocked users: |
3ms |
| others: | 349ms |
| total: | 563ms |

| 0 / 0 |
