Package java.security

Examples of java.security.SecureRandom.nextFloat()


  */
  private static String generateRandomString() {
    final StringBuffer res = new StringBuffer();
    final Random rnd = new SecureRandom();
    for (int i = 0; i < 32; i++) {
      int pos = (int) (rnd.nextFloat() * CHARS.length());
      res.append(CHARS.charAt(pos));
    }
 
    return res.toString();
  }
View Full Code Here


   */
  public final String crypt(String password) throws java.security.NoSuchAlgorithmException {
    StringBuilder salt = new StringBuilder();
    SecureRandom randgen = new SecureRandom();
    while (salt.length() < 8) {
      int index = (int) (randgen.nextFloat() * itoa64.length());
      salt.append(itoa64.substring(index, index + 1));
    }
    return crypt(password, salt.toString());
  }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.