-1

I want to encode some value and pass it to the server. My concern is will my secret key be portable to the server side? For encode I want to get bytes as MyString.getBytes(), but server can keep Strings in a different way, so when he try to decode my message the result will be wrong.

Could you tell me please a right way how to make strings portable, independent from platforms?

  • 2
    Why wouldn't the String be "portable" if you use identical encryption/decryption and encoding on each end..? – FThompson Dec 14 '12 at 06:44

2 Answers2

0

For this, you can use Base64 Encoding/Decoding formula. here's the introduction for the BASE64 for android.

and Example to encode/decode.

Community
  • 1
  • 1
V.J.
  • 9,492
  • 4
  • 33
  • 49
0

For portability, you should use String.getBytes(Charset) and the corresponding constructor. You need to specify the same charset on the client and the server. If you don't specify a charset when encoding/decoding strings to bytes the result depends on the default charset of the platform and is therefore not portable.

Gustav Grusell
  • 1,166
  • 6
  • 7