I'm generating a random string using:
private String generateSafeToken() {
SecureRandom random = new SecureRandom();
byte bytes[] = new byte[512];
random.nextBytes(bytes);
return bytes.toString();
}
This gives a string of length 11 such as [B@70ffc557
. How can I make this above method return a string of a specified length. For example 20 characters?