w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
How to generate a SecureRandom array, convert it to a string, and then convert it back to array

then, I convert it to a string like this:

Don't do that!

You have two problems here:

  • this constructor will use the default encoding;
  • even if you used UTF-8 as an encoding, some byte sequences just cannot be encoded to chars!

You should not use String to hold binary data; or use a string-based encoding, such as Base64.

For more information, see CharsetDecoder and CodingErrorAction.

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.