List of usage examples for java.security SecureRandom toString
@Override
public String toString()
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()); }