I am looking for mechanism to generate random unique alpha numeric key for resetting user password.
I've goggled a lot in this direction, but looks like this thing is not obvious thing.
I've tried something like that:
new String(encodeBase64URLSafe(UUID.randomUUID()));
But after reading the following article: Is UUID.randomUUID() suitable for use as a one-time password? looks like that this way is not fully correct.
It would be really appreciate if you answer on the following questions:
- Which is secure way to generate such token using UUID?
- Do we need to convert UUID string to base64 in order to have safe URLs or it would be enough to remove dashes from generated string?
- Would be it correct to use mechanism from this link in such purpouses How to generate a random alpha-numeric string?, why?