Java string to bytearray back to string -


I have a client and server Java application for which the encrypted text needs to pass through each other. I am using encryption which encrypts the text I want.

The problem is that readline () does not accept wire strings that are XORed and will only be accepted if it is in bytes.

So I changed my plain text (string) into a byte array on the client side, and tried to convert it back to the server side on the string.

Unfortunately, the result is me, I'm still looking for white text.

Does anyone know how to change the bitter in the original string? Or is there a better way to send XROM encrypted text through the readline () function?

After you have applied something like XOR, you end up with uncontrolled binary data - < Em> not an encoded string

The arbitrary binary is to be used in conventional way of changing the text - Do not try to create a new string from now, then your process will be something like this: / P>

  • Start with plain text in the form of a string.
  • Using plain text UTF-8, UTF-16 or something similar. Use the Do not platform default encoding, or some restrictions like ASCII now have a byte array.
  • Apply your encryption (XOR is very weak, but let's leave it aside.) You still have a byte array.
  • Apply base 64 encoding to get the string.

Then you need to decrypt ...

  • To convert your string to a byte array, base 64 decoding .
  • Apply your binary decryption process (e.g., XOR again). You still have a byte array.
  • Now decode the byte array in that string, e.g. To get the original string back, with new string (Data, UTF-8 Chassetset) .

There are several Java Base 64 libraries available, such as (you want encodeToString (byte []) and decode (string) methods.)


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -