Several ways to generate SMS verification codes

Comparison of several ways to generate SMS verification codes

1.Method 1
String code = (Math.random()+"").substring(2,8)
2.Method 2
String code = String.valueOf((int)(Math.random()*9+1)*(Math.pow(10,5)));
The first method takes 10 times as long as the second method to loop the same number of times.

Guess you like

Origin blog.csdn.net/hsadfdsahfdsgfds/article/details/114106767