Generate a random salt.

@return
the random salt.
@throws NoSuchAlgorithmException
the NoSuchAlgorithmException.
14988
public static byte[] generateSalt() throws NoSuchAlgorithmException {
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] salt = new byte[8];
        random.nextBytes(salt);
        return salt;
    }
482943
public static function make()
    {
        $salt = date('Y-m-d H:i:s', time() - 10000) . uniqid(rand(), true);

        $token = base64_encode(base64_encode(openssl_random_pseudo_bytes(6)) . $salt);

        return Str::slice(hash('sha256', $token), 1, 62);
    }
74304
public static synchronized Random getThreadLocalRandom() {
        if(threadLocalRandom == null) {
            threadLocalRandom = new ThreadLocal<Random>() {
                /**
                 * Builds a Random object using the globalSeed (if available).
                 * 
                 * @return 
                 */
                @Override
                protected Random initialValue() {
                    if(globalSeed == null) {
                        return new Random();
                    }
                    else {
                        return new Random(globalSeed);
                    }
                }
            };
        }
        return threadLocalRandom.get();
    }
1346506
protected static function generateSalt(): string
    {
        $result = '';

        static::validateSaltMinLength();

        $pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $poolSize = strlen($pool);
        for ($i = 0; $i < static::$saltMinLength; $i++) {
            $result .= $pool[rand(0, $poolSize - 1)];
        }

        return $result;
    }
409226
public KeyPair generateKeyPair() throws NoSuchAlgorithmException {
        LOGGER.info("Generating new key pair");
        final KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA");
        final SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        keyGen.initialize(4096, random);
        return this.keyPair = keyGen.generateKeyPair();
    }
1029308
public static byte[] keyGenPrivate(byte[] randomBytes) throws NoSuchAlgorithmException, DigestException {

        if (randomBytes.length < 32) {
            throw new RuntimeException("Random bytes too small");
        }

        // Hashing Random Bytes instead of using random bytes directly
        // Just in case as reference ed255519 implementation do same
        MessageDigest digest = MessageDigest.getInstance("SHA-256");
        digest.digest(randomBytes, 0, randomBytes.length);
        byte[] privateKey = digest.digest();

        // Performing bit's flipping
        privateKey[0] &= 248;
        privateKey[31] &= 127;
        privateKey[31] |= 64;

        return privateKey;
    }
1023178
public function salt($password, $member = null)
    {
        $generator = new RandomGenerator();
        return sprintf('%02d', self::$cost) . '$' . substr($generator->randomToken('sha1'), 0, 22);
    }
455843
public static String getHash(final String password, final String salt) {

		if (StringUtils.isEmpty(salt)) {

			return getSimpleHash(password);

		}

		return DigestUtils.sha512Hex(DigestUtils.sha512Hex(password).concat(salt));

	}
326165
public function generate()
    {
        $str     = '';
        $keysize = strlen($this->_alphabet);

        for ($i = 0; $i < $this->_length; ++$i) {
            $str .= $this->_alphabet[\Sodium\randombytes_uniform($keysize)];
        }

        return $str;
    }
200195
public List<T> generateRandomCandidate(Random rng)
    {
        List<T> candidate = new ArrayList<T>(elements);
        Collections.shuffle(candidate, rng);
        return candidate;
    }
265799
public static String gen(String... arr) throws NoSuchAlgorithmException {
    Arrays.sort(arr);
    StringBuilder sb = new StringBuilder();
    for (String a : arr) {
      sb.append(a);
    }
    return DigestUtils.sha1Hex(sb.toString());
  }
706643
protected synchronized Random getRandom() {
        if (this.random == null) {
            try {
                Class clazz = Class.forName(randomClass);
                this.random = (Random) clazz.newInstance();
                long seed = System.currentTimeMillis();
                char[] entropy = getEntropy().toCharArray();
                for (int i = 0; i < entropy.length; i++) {
                    long update = ((byte) entropy[i]) << ((i % 8) * 8);
                    seed ^= update;
                }
                this.random.setSeed(seed);
            } catch (Exception e) {
                this.random = new java.util.Random();
            }
        }
        return (this.random);
    }
1119076
public Random getRandom() {
        try {
            if (threadRandom.get() == null) {
                Random t = (Random) randomClass.newInstance();
                if (t.getStatePointer() != null) {
                    // TODO: attach this thing to deallocator
                    // if it's stateless random - we just don't care then
                }
                threadRandom.set(t);
                return t;
            }


            return threadRandom.get();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
532048
public static function createSalt()
    {
        $salt = Random::createString(self::SALT_START_LENGTH);
        $base64 = base64_encode($salt);
        $salt = self::convertAlphabets($base64);
        return Binary::getSlice($salt, 0, self::SALT_FINAL_LENGTH);
    }
1339656
CipherBox newReadCipher() throws NoSuchAlgorithmException {
        BulkCipher cipher = cipherSuite.cipher;
        CipherBox box;
        if (isClient) {
            box = cipher.newCipher(protocolVersion, svrWriteKey, svrWriteIV,
                                   sslContext.getSecureRandom(), false);
            svrWriteKey = null;
            svrWriteIV = null;
        } else {
            box = cipher.newCipher(protocolVersion, clntWriteKey, clntWriteIV,
                                   sslContext.getSecureRandom(), false);
            clntWriteKey = null;
            clntWriteIV = null;
        }
        return box;
    }
448019
private function getSalt() {
		$salt = $this->getIdentifier();

		$bytes = $this->getRandomBytes($this->getSaltLength());

		$salt .= $this->encodeBytes($bytes);

		return $salt;
	}
521989
def gen_salt(length):
    """"""
    if length <= 0:
        raise ValueError('requested salt of length <= 0')
    return ''.join(_sys_rng.choice(SALT_CHARS) for _ in range_type(length))