I am trying to generate random number with special characters
what i do for simple integers is
Random randomGenerator = new Random();
int randomNumber = randomGenerator.nextInt();
what can i do to get some thing like this in my random numbers
String salt = "Random$SaltValue#WithSpecialCharacters12@$@4&#%^$*";
thanks
You can try the following:
The code:
final String alphabet = "<Your special characters>";
final int N = alphabet.length();
Random rd = new Random();
int iLength = <length you want>;
StringBuilder sb = new StringBuilder(iLength);
for (int i = 0; i < iLength; i++) {
sb.append(alphabet.charAt(rd.nextInt(N)));
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With