1

I am currently writing java client and server chat application using socket programming in which I am exchanging data using JSON objects.When I try to store byte array containing encrypted data, and sends udp data packet from client to server, byte data gets corrupted.

As per few posts, JSON object cannot handle byte array data. So is there any way by which I can send multiple encrypted data byte arrays using UDP packet from client to server?

4
  • 1
    JSON objects absolutely can handle byte arrays. Here is one example using Jackson. Commented Nov 30, 2013 at 5:09
  • but is same possible with encrypted data also as it contains many illegal characters? Commented Nov 30, 2013 at 5:21
  • 2
    You should encode the binary data in a printable form, i.e. Base64. See stackoverflow.com/a/2054226/18157 Commented Nov 30, 2013 at 6:05
  • Thanks Jim and Vidya,I will try and get back. Commented Nov 30, 2013 at 6:25

1 Answer 1

1

As noted in the comments, you can encode binary data as text, using the very old and well-known technique of Base64 encoding. In Java you can do this using javax.xml.bind.DatatypeConverter.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.