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?
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.