Java Salt Value Create generateSalt()

Here you can find the source of generateSalt()

Description

generate Salt

License

Open Source License

Declaration

public static String generateSalt() 

Method Source Code

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

import java.security.SecureRandom;

public class Main {
    private static final SecureRandom rand = new SecureRandom();
    private static final String saltChars = "ABCDEFGHIJGMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890-_=+[]{};:.,<>/?\\|~`";

    public static String generateSalt() {
        return generateSalt(rand.nextInt(10) + 5);
    }//w w  w.  j  av a 2  s.  com

    public static String generateSalt(int length) {
        char[] array = new char[length];

        for (int i = 0; i < length; i++) {
            array[i] = saltChars.charAt(rand.nextInt(saltChars.length()));
        }

        return new String(array);
    }
}

Related

  1. createSalt(int byte_length)
  2. generateSalt()
  3. generateSalt()
  4. generateSalt()
  5. generateSalt()
  6. generateSalt()
  7. generateSalt()
  8. generateSalt()
  9. generateSalt()