Quantcast
Channel: How to generate a random alpha-numeric string - Stack Overflow
Browsing all 48 articles
Browse latest View live

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 Article


Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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 Article


Answer 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 Article

Answer 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 Article

Answer 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

Browsing all 48 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>