Java Salt Value Create getNewSalt()

Here you can find the source of getNewSalt()

Description

get New Salt

License

Open Source License

Declaration

public static String getNewSalt() 

Method Source Code


//package com.java2s;
/*//from  w ww. j  a  va2  s  .co  m
 * This file is part of MailAdmin.
 *
 *     MailAdmin is free software: you can redistribute it and/or modify
 *     it under the terms of the GNU General Public License as published by
 *     the Free Software Foundation, either version 2 of the License, or
 *     (at your option) any later version.
 *
 *     MailAdmin is distributed in the hope that it will be useful,
 *     but WITHOUT ANY WARRANTY; without even the implied warranty of
 *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *     GNU General Public License for more details.
 *
 *     You should have received a copy of the GNU General Public License
 *     along with MailAdmin.  If not, see <http://www.gnu.org/licenses/>.
 */

import java.util.Random;

public class Main {
    public static String getNewSalt() {
        char[] validChars = "abcdefghijklmnoqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVXYZ0123456789".toCharArray();
        StringBuilder stringBuilder = new StringBuilder();
        for (int i = 0; i < 16; i++) {
            stringBuilder.append(validChars[(new Random()).nextInt(validChars.length - 1)]);
        }

        //   return stringBuilder.toString();
        return stringBuilder.toString();
    }
}

Related

  1. generateSaltAESPBKDF2()
  2. generateSaltedPassword(final String password, byte[] salt, int iterationsCount, String hmacName)
  3. generateSaltedSHAHash(String algorithm, String input, String salt)
  4. generateSaltOfLength(int length)
  5. getMd5Salt()
  6. getSalt()
  7. getSaltDES(int snmpEngineBoots)
  8. getSaltedString(String in)
  9. getSaltString()