Example usage for java.security SecureRandom toString

List of usage examples for java.security SecureRandom toString

Introduction

In this page you can find the example usage for java.security SecureRandom toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a Human-readable string representation of this SecureRandom .

Usage

From source file:fr.cph.stock.security.Security.java

/**
 * Generate a salt, a random key, en encrypt it
 * //from   w  w  w.  j  av a  2 s  . c om
 * @return a key encrypted
 * @throws NoSuchAlgorithmException
 *             the NoSuchAlgorithmException
 * @throws UnsupportedEncodingException
 *             the UnsupportedEncodingException
 */
public static String generateSalt() throws NoSuchAlgorithmException, UnsupportedEncodingException {
    SecureRandom random = new SecureRandom();
    return Security.encodeToSha256(random.toString());
}

From source file:fr.cph.stock.security.SecurityServiceImpl.java

/**
 * Generate a salt, a random key, en encrypt it
 *
 * @return a key encrypted//  www .  jav  a 2s  .  co m
 * @throws NoSuchAlgorithmException     the NoSuchAlgorithmException
 * @throws UnsupportedEncodingException the UnsupportedEncodingException
 */
@Override
public String generateSalt() throws NoSuchAlgorithmException, UnsupportedEncodingException {
    final SecureRandom random = new SecureRandom();
    return encodeToSha256(random.toString());
}