Errai 3.0.1-SNAPSHOT

org.jboss.errai.bus.server.util
Class SecureHashUtil

java.lang.Object
  extended by org.jboss.errai.bus.server.util.SecureHashUtil

public class SecureHashUtil
extends Object

A utility class for producing secure hashes throughout the Errai code where needed.

Author:
Mike Brock

Constructor Summary
SecureHashUtil()
           
 
Method Summary
static String hashToHexString(byte[] hash)
           
static String nextSecureHash()
          Returns a new secure hash using the SHA-256 hash function salted with the SHA1PRNG random number generator.
static String nextSecureHash(String algorithm)
          Returns a new secure hash using the specified hash function salted with the SHA1PRNG random number generator.
static String nextSecureHash(String algorithm, byte[]... additionalSeed)
          Get a new secure hash.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SecureHashUtil

public SecureHashUtil()
Method Detail

nextSecureHash

public static String nextSecureHash()
Returns a new secure hash using the SHA-256 hash function salted with the SHA1PRNG random number generator.

Returns:
a hex string representation of the hash.

nextSecureHash

public static String nextSecureHash(String algorithm)
Returns a new secure hash using the specified hash function salted with the SHA1PRNG random number generator.

Parameters:
algorithm - The hash function to use (SHA-1, SHA-256, MD5).
Returns:
a hex string representation of the hash.

nextSecureHash

public static String nextSecureHash(String algorithm,
                                    byte[]... additionalSeed)
Get a new secure hash. Optionally accepts additional seeds which will be used to salt the hash function. A secure random number generator (SHA1PRNG) is used as a base salt, compounded with a time-based hash seed.

Parameters:
algorithm - The hash function to use (SHA-1, SHA-256, MD5).
additionalSeed - A vararg of additional byte[] seeds to optionally add additional salts to the hash function.
Returns:
a hex string representation of the hash.

hashToHexString

public static String hashToHexString(byte[] hash)

Errai 3.0.1-SNAPSHOT

Copyright © 2013-2014 JBoss, a division of Red Hat. All Rights Reserved.