.NET TripleDESCryptoServiceProvider equivalent in Java

后端 未结 4 682
温柔的废话
温柔的废话 2020-12-25 09:26

Please, just don\'t ask me why. I just have this code in .NET that encrypt/decrypt strings of data. I need now to make \'exactly\' the same funcionality in java. I have trie

4条回答
  •  青春惊慌失措
    2020-12-25 09:43

    You got a few problems,

    1. Your key must be 24 bytes if you want generate the same key materials on both .NET and Java.
    2. The IV must be block size, which is 8 bytes for Triple DES.
    3. In Java, you need to specify the default mode and padding, which is "DESede/CBC/NoPadding".

    Once you make these changes, you should be able to decrypt it on Java side.

提交回复
热议问题