Java ID Value Create generateSalt()

Here you can find the source of generateSalt()

Description

Return a randomly-generated 16 character alphanumeric value (a-z, A-Z, 0-9)

License

Open Source License

Return

String salt

Declaration

public static String generateSalt() 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Random;

public class Main {
    /**/*from  w  w w .j  ava  2s.com*/
     * Return a randomly-generated 16 character alphanumeric value
     * (a-z, A-Z, 0-9)
     *
     * @return String salt
     */
    public static String generateSalt() {
        String validChars = "abcdefghijlmnopqrstuvwxyzABCDEFGHIKJLMNOPQRSTUVWXYZ0123456789";
        int length = 16;
        Random rand = new Random();
        StringBuilder sb = new StringBuilder(length);
        while (sb.length() != length)
            sb.append(validChars.charAt(rand.nextInt(validChars.length())));
        return sb.toString();
    }
}

Related

  1. generateID(int seed)
  2. generateID(String origin)
  3. generateId(String salt)
  4. generateSalt()
  5. generateSalt()
  6. generateUniqueId()
  7. generateUniqueId()
  8. generateUniqueIdentity()
  9. generateUniqueName(String kind)