06-05-2012 05:33 PM - edited 06-06-2012 04:16 AM
Welcome to the forums.
It is unusual to wish to have the encrypted data in hexadecimal. As I understand it, most people will, if they have to send Binary data in text form, use Base64, which I think is more efficient.
If you wish to convert a byte array to hex String, then something like this will do it:
So then the question is how do you use DES. This unfortunately is not a trivial exercise, because there are actually quite a number of flavors of DES, depending on single or triple, the Block chaining that you use, the initial vector and the padding.
If you look at your JavaDoc for DESEncryptorEngine, you will find a link it it that points you at a code sample.
Can I recommend that you review AES. It is a more efficient encryption, and more secure. I would not use DES for anything unless I had no choice.
06-05-2012 11:32 PM
hi peter thx for your explaination..
here is my code
06-06-2012 04:38 AM
Interesting. code looks fine.
I would appreciate you actually dumping off the hex for the bytes you put into the encryption and what you get out. For example, can you change:
engine.encrypt(text.getBytes(), 0, data, 0);
byte  plainText = text.getBytes(),
System.out.println("Plain text(" + plainText.length + "): " + byteArrayToHexString(plainText));
engine.encrypt(plainText, 0, data, 0);
System.out.println("Cipher text(" + data.length + "): " + byteArrayToHexString(data));
System.out.println("Key(" + ba.length + "): " + byteArrayToHexString(ba));
I'd be interested to see what happens if you put the same values in as are in the sample on the page you pointed at. You won't be able to do that with your current code, so you could change your current code so that you type in hex values rather than characters. I appreciate that is probably not what you want to do long term but it might help us with this problem.