I have the below code which uses java.util.Random
, now I want to change to java.security.SecureRandom
. How do I do the same operations with SecurRandom?
int rand = 0;
for (int i = 0; i < 8; i++) {
rand = (int) (Math.random() * 3);
switch (rand) {
case 0:
c = '0' + (int) (Math.random() * 10);
break;
case 1:
c = 'a' + (int) (Math.random() * 26);
break;
case 2:
c = 'A' + (int) (Math.random() * 26);
break;
}
}