How to generate a random alpha-numeric string?
I've been looking for a simple Java algorithm to generate a pseudo-random alpha-numeric string. In my situation it would be used as a unique session/key identifier that would "likely" be unique over...
View ArticleAnswer by Riley Jones for How to generate a random alpha-numeric string?
public static String RandomAlphanum(int length) { String charstring = "abcdefghijklmnopqrstuvwxyz0123456789"; String randalphanum = ""; double randroll; String randchar; for (double i = 0; i <...
View ArticleAnswer by Chuong Tran for How to generate a random alpha-numeric string?
I'm using library from apache to generate alphanumeric stringimport org.apache.commons.lang3.RandomStringUtils;String keyLength = 20;RandomStringUtils.randomAlphanumeric(keylength);It's fast and simple!
View ArticleAnswer by Muxammed Gafarov for How to generate a random alpha-numeric string
public class Utils { private final Random RANDOM = new SecureRandom(); private final String ALPHABET = "0123456789QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm"; private String...
View ArticleAnswer by Mayank for How to generate a random alpha-numeric string
I am using a very simple solution using Java 8. Just customize it according to your needs....import java.security.SecureRandom;...//Generate a random String of length between 10 to 20.//Length is also...
View ArticleAnswer by F_SO_K for How to generate a random alpha-numeric string
You can do this in one line with no external libraries.int length = 12;String randomString = new Random().ints(48, 122).filter(i -> (i < 58 || i > 64) && (i < 91 || i >...
View ArticleAnswer by cwtuan for How to generate a random alpha-numeric string
Given the some characters (AllCharacters), you could pickup a character in the string randomly. Then use-for loop to get random charcter repeatedly.public class MyProgram { static String...
View ArticleAnswer by Chamith Malinda for How to generate a random alpha-numeric string
With come modifications to gurantee to have a number in the returned string. private static String generateRandomCouponMethod3(int lengthOfString){ final String alphabet =...
View Article