javax.crypto: encrypte a string with Standard DES encryption with a 2-char SALT

C

ClaudiaE

Hello,

can anyone help me? I want to encrypt a string with DES encryption in
Java. I have a 2 char salt for encryption. I have no key. Can anyone
tell me the way to do that?

Thanks,

Claudia E.
 
H

Hans Granqvist

Hello,

can anyone help me? I want to encrypt a string with DES encryption in
Java. I have a 2 char salt for encryption. I have no key. Can anyone
tell me the way to do that?

Thanks,

Claudia E.

How about . . .

Key key = KeyGenerator.getInstance("DESede").generateKey();
IvParameterSpec iv = new IvParameterSpec(<your bytes>);

Cipher cipher = Cipher.getInstance("DESede/CBC/NoPadding");
cipher.init(Cipher.ENCRYPT_MODE, key, iv);
. . .
byte[] encrypted = cipher.doFinal(<your String>.toBytes());

.. . . but you'll have to figure out padding yourself. You can change
the instance of the cipher or pad using your own scheme by finding
the block size of the cipher.

-Hans
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,539
Members
45,024
Latest member
ARDU_PROgrammER

Latest Threads

Top