I want to generate a random bytes using SecureRandom and encode it as base64 to be pass in a URL parameter.
My requirements is: it must atleast hard to predict or brute force, but also short enough not to consume too much memory.
I came up with this code where I put 8 bytes. Is it enough?
SecureRandom rand = new SecureRandom();
byte[] randomBytes = new byte[8];
rand.nextBytes(randomBytes);
Base64 base64 = new Base64();
String result = base64.encodeBase64URLSafeString(randomBytes);
Also, I am planning to append at least a timestamp to make it more unique. UUID is not my option since its too big. Maybe a portion of timestamp, would the be a good idea?