Creates an new instance with only its {@code algorithmName} set - no hashing is performed. <p/> Because all other constructors in this class hash the {@code source} constructor argument, this constructor is useful in scenarios when you have a byte array that you know is already hashed and just want to set the bytes in their raw form directly on an instance. After using this constructor, you can then immediately call {@link #setBytes setBytes} to have a fully-initialized instance. <p/> <b>N.B.</b>The algorithm identified by the {@code algorithmName} parameter must be available on the JVM. If it is not, a {@link UnknownAlgorithmException} will be thrown when the hash is performed (not at instantiation).
Creates an {@code algorithmName}-specific hash of the specified {@code source} with no {@code salt} using a single hash iteration. <p/> This is a convenience constructor that merely executes <code>this( algorithmName, source, null, 1);</code>. <p/> Please see the {@link #SimpleHash(string algorithmName, Object source, Object salt, int numIterations) SimpleHashHash(algorithmName, Object,Object,int)} constructor for the types of Objects that may be passed into this constructor, as well as how to support further types.
Creates an {@code algorithmName}-specific hash of the specified {@code source} using the given {@code salt} using a single hash iteration. <p/> It is a convenience constructor that merely executes <code>this( algorithmName, source, salt, 1);</code>. <p/> Please see the {@link #SimpleHash(string algorithmName, Object source, Object salt, int numIterations) SimpleHashHash(algorithmName, Object,Object,int)} constructor for the types of Objects that may be passed into this constructor, as well as how to support further types.
Creates an {@code algorithmName}-specific hash of the specified {@code source} using the given {@code salt} a total of {@code hashIterations} times. <p/> By default, this class only supports Object method arguments of type {@code byte[]}, {@code char[]}, {@link string}, {@link java.io.File File}, {@link java.io.InputStream InputStream} or {@link hunt.shiro.util.ByteSource ByteSource}. If either argument is anything other than these types a {@link hunt.shiro.codec.CodecException CodecException} will be thrown. <p/> If you want to be able to hash other object types, or use other salt types, you need to override the {@link #toBytes(Object) toBytes(Object)} method to support those specific types. Your other option is to convert your arguments to one of the default supported types first before passing them in to this constructor}.
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.
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.
Returns the {@link java.security.MessageDigest MessageDigest} algorithm name to use when performing the hash.
Hashes the specified byte array without a salt for a single iteration.
Hashes the specified byte array using the given {@code salt} for a single iteration.
Hashes the specified byte array using the given {@code salt} for the specified number of iterations.
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.
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.
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.
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.
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.
Converts a given object into a {@code ByteSource} instance. Assumes the object can be converted to bytes.
Simply returns toHex().hashCode();
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.
Simple implementation that merely returns {@link #toHex() toHex()}.
A {@code Hash} implementation that allows any {@link java.security.MessageDigest MessageDigest} algorithm name to be used. This class is a less type-safe variant than the other {@code AbstractHash} subclasses (e.g. {@link Sha512Hash}, etc), but it does allow for any algorithm name to be specified in case the other subclass implementations do not represent an algorithm that you may want to use. <p/> As of Shiro 1.1, this class effectively replaces the (now-deprecated) {@link AbstractHash} class. It subclasses {@code AbstractHash} only to retain backwards-compatibility.