1

I'm using this code for DES-encryption: How do I use 3des encryption/decryption in Java?

Now, I want to encrypt a byte array with this. How can I do that?

I have changed the name of algo from DESede to DES and am obviously using an 8-byte key (not 24).

Community
  • 1
  • 1
vish4071
  • 5,135
  • 4
  • 35
  • 65

1 Answers1

0

Cipher#doFinal takes and returns byte[]. The only thing that you need to do is removing the additional encoding steps like

message.getBytes("utf-8") // before encryption

and

new String(plainText, "UTF-8") // after decryption

Obviously, you need to change the method signature from String to byte[] for both encryption and decryption.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222