-5

I am writing a new Android application that require the users to register and the system need to send emails to give them a code for email verification.

The random code need to be a 6-digit code that consisting numbers with uppercase alphabet, for example, 6H94BA. I have done some research and still cannot find anything. How to do that?

Sky
  • 1,435
  • 1
  • 15
  • 24
User1239
  • 3
  • 3
  • 1
    This is commonly done in the backend - not the Android application itself. There would be no safety benefit. – dipdipdip Jun 29 '17 at 11:24
  • 1
    It is really not clear what you are asking for. You put up an unclear description of a work flow; but as said - it is not even clear where you expect what to happen. – GhostCat Jun 29 '17 at 11:25

2 Answers2

1

You can do this.

 public static String getRandomString(){
    return UUID.randomUUID().toString().subString(0,5);
}
Dishonered
  • 8,449
  • 9
  • 37
  • 50
1

Try this:

SecureRandom random = new SecureRandom();
String randomCode = new BigInteger(30, random).toString(32).toUpperCase();
Sky
  • 1,435
  • 1
  • 15
  • 24