Sha1Hash

Generates an SHA-1 Hash (Secure Hash Standard, NIST FIPS 180-1) from a given input <tt>source</tt> with an optional <tt>salt</tt> and hash iterations. <p/> See the {@link SimpleHash SimpleHash} parent class JavaDoc for a detailed explanation of Hashing techniques and how the overloaded constructors function.

Constructors

this
this()
Undocumented in source.
this
this(Object source)
Undocumented in source.
this
this(Object source, Object salt)
Undocumented in source.
this
this(Object source, Object salt, int hashIterations)
Undocumented in source.

Members

Static functions

fromBase64String
Sha1Hash fromBase64String(string base64)
Undocumented in source. Be warned that the author may not have intended to support it.
fromHexString
Sha1Hash fromHexString(string hex)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

ALGORITHM_NAME
enum string ALGORITHM_NAME;
Undocumented in source.

Inherited Members

From SimpleHash

convertSourceToBytes
ByteSource convertSourceToBytes(Object source)

Acquires the specified {@code source} argument's bytes and returns them in the form of a {@code ByteSource} instance. <p/> This implementation merely delegates to the convenience {@link #toByteSource(Object)} method for generic conversion. Can be overridden by subclasses for source-specific conversion.

convertSaltToBytes
ByteSource convertSaltToBytes(Object salt)

Acquires the specified {@code salt} argument's bytes and returns them in the form of a {@code ByteSource} instance. <p/> This implementation merely delegates to the convenience {@link #toByteSource(Object)} method for generic conversion. Can be overridden by subclasses for salt-specific conversion.

toByteSource
ByteSource toByteSource(Object o)

Converts a given object into a {@code ByteSource} instance. Assumes the object can be converted to bytes.

getAlgorithmName
string getAlgorithmName()

Returns the {@link java.security.MessageDigest MessageDigest} algorithm name to use when performing the hash.

getSalt
ByteSource getSalt()
Undocumented in source. Be warned that the author may not have intended to support it.
getIterations
int getIterations()
Undocumented in source. Be warned that the author may not have intended to support it.
getBytes
byte[] getBytes()
Undocumented in source. Be warned that the author may not have intended to support it.
setBytes
void setBytes(byte[] alreadyHashedBytes)

Sets the raw bytes stored by this hash instance. <p/> The bytes are kept in raw form - they will not be hashed/changed. This is primarily a utility method for constructing a Hash instance when the hashed value is already known.

setIterations
void setIterations(int iterations)

Sets the iterations used to previously compute AN ALREADY GENERATED HASH. <p/> This is provided <em>ONLY</em> to reconstitute an already-created Hash instance. It should ONLY ever be invoked when re-constructing a hash instance from an already-hashed value.

setSalt
void setSalt(ByteSource salt)

Sets the salt used to previously compute AN ALREADY GENERATED HASH. <p/> This is provided <em>ONLY</em> to reconstitute a Hash instance that has already been computed. It should ONLY ever be invoked when re-constructing a hash instance from an already-hashed value.

hash
byte[] hash(byte[] bytes)

Hashes the specified byte array without a salt for a single iteration.

hash
byte[] hash(byte[] bytes, byte[] salt)

Hashes the specified byte array using the given {@code salt} for a single iteration.

hash
byte[] hash(byte[] bytes, byte[] salt, int hashIterations)

Hashes the specified byte array using the given {@code salt} for the specified number of iterations.

isEmpty
bool isEmpty()
Undocumented in source. Be warned that the author may not have intended to support it.
toHex
string toHex()

Returns a hex-encoded string of the underlying {@link #getBytes byte array}. <p/> This implementation caches the resulting hex string so multiple calls to this method remain efficient. However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the next time this method is called.

toBase64
string toBase64()

Returns a Base64-encoded string of the underlying {@link #getBytes byte array}. <p/> This implementation caches the resulting Base64 string so multiple calls to this method remain efficient. However, calling {@link #setBytes setBytes} will null the cached value, forcing it to be recalculated the next time this method is called.

toString
string toString()

Simple implementation that merely returns {@link #toHex() toHex()}.

opEquals
bool opEquals(Object o)

Returns {@code true} if the specified object is a Hash and its {@link #getBytes byte array} is identical to this Hash's byte array, {@code false} otherwise.

toHash
size_t toHash()

Simply returns toHex().hashCode();

Meta