Encrypting and Decrypting Using Java: Unable to get same output

后端 未结 3 1701
忘了有多久
忘了有多久 2020-12-07 23:58

I am trying to learn and test the java 1.6 encryption/decryption API. I want to know what I am doing wrong and what I am missing in terms of knowledge.

In the code

3条回答
  •  被撕碎了的回忆
    2020-12-08 00:17

    Here's the description from JDK doc:

    DESKeySpec
    public DESKeySpec(byte[] key)
               throws InvalidKeyException
    Creates a DESKeySpec object using the first 8 bytes in key as the key material for the DES key. 
    The bytes that constitute the DES key are those between key[0] and key[7] inclusive. 
    

    DESKeySpec uses only the first 8 bytes of byte[] as key. Thus the actual keys in used are identical in your example.

提交回复
热议问题