Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>From an old code:</p> <pre><code> public void testSymCypher(SecretKey k, String str) throws BadPaddingException, IllegalBlockSizeException, InvalidAlgorithmParameterException, InvalidKeyException, NoSuchAlgorithmException, NoSuchPaddingException { Cipher cip = Cipher.getInstance("DESede/CBC/PKCS5Padding"); cip.init(Cipher.ENCRYPT_MODE,k); byte[] ciphered = cip.doFinal(str.getBytes()); byte iv[] = cip.getIV(); // printing the ciphered string printHexadecimal(ciphered); IvParameterSpec dps = new IvParameterSpec(iv); cip.init(Cipher.DECRYPT_MODE,k,dps); byte[] deciphered = cip.doFinal(ciphered); // printing the deciphered string printHexadecimal(deciphered); } </code></pre> <p>Notice than other usage of DESede are available in Java JDK 6:</p> <ul> <li>DESede/CBC/NoPadding (168)</li> <li>DESede/CBC/PKCS5Padding (168)</li> </ul> <p>There is also ECB mode available (but be carreful to not use it twice !!), you don't need to use iv part in this case:</p> <ul> <li>DESede/ECB/NoPadding (168)</li> <li>DESede/ECB/PKCS5Padding (168) </li> </ul> <p>To generate key for DESede:</p> <pre><code> KeyGenerator generatorDes = KeyGenerator.getInstance("DESede"); SecretKey skaes = generatorDes.generateKey(); </code></pre> <p>Finally I recommand reading <a href="http://java.sun.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html" rel="nofollow noreferrer" title="Java ™ Cryptography Architecture (JCA) Reference Guide">this document</a> from SUN if you need to work on Java and Cryptography</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload