Hi I am facing a very critical problem.....i am into cryptography and using DES algorithm to encrypt and decrypt a plain text..... The main problem lies when i encrypt a particular plain text we get a set of weird characters being generated now when i try to send these characters through a socket then at the other end the reading is not interpreted properly....by this i mean that all characters in the ascii range 148-160 have a representation of a '?')(try printing on the console) and when any character(generated after encrypting) of this range is read at the other end it is read as a character with ascii value 63 which corresponds to real '?'.Why does this happen....
"archies", It appears that you had a valid display name and have changed it so it is no longer valid. Please change it back immediately, since accounts with invalid display names get deleted, often without warning.
I infer that you are encrypting some bytes and then converting them to a String using something like
byte encryptedBytes = cipher.doFinal(planeTextBytes); String encrypted = new String(encryptedBytes);
This is almost certainly doomed to failure because not all byte combinations convert (reversibly) to a String. If you realy do need to send ASCII character then your best bet is to Base64 or Hex encode the encrypedBytes.
I try not to convert encrypted bytes or hash bytes to a String. The only time I have needed to is when I had to put hash bytes into a DB table where I was not allowed (customer forbade it) to to change the table structure in any way.
The following is my standard demonstration of DES encryption and shows an example of the use of Base64 to encode encrypted data.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Hi All Thanks for your response ....but someone said that i should convert the characters to byte from and then send it ...but what happens is that characters above the ascii value 127 does not gets stored in a byte(as byte ranges from -128 to 127) and thus these values are stored wrongly .So i went in for writer class which uses characters rather then having stream classes and thus faced that problem.......But i basically dont understand how are characters interpreted wrongly...You all can try sending characters within ascii range 148-160 and receive them at the other end...They are interpreted wrongly(read as character with ascii 63).
As David has already asked you (see above), please change your display name to comply with our policy. You need a real-sounding first and last name. Don't post again before making the change. Thank you.