Class MessageDigestValue
- java.lang.Object
-
- com.helger.security.messagedigest.MessageDigestValue
-
- All Implemented Interfaces:
com.helger.commons.io.IHasByteArray,com.helger.commons.io.IHasInputStream,com.helger.commons.io.IHasInputStreamAndReader,com.helger.commons.lang.IHasSize
@Immutable public class MessageDigestValue extends Object implements com.helger.commons.io.IHasByteArray
Represents a single message digest value as the combination of the algorithm and the digest bytes.- Author:
- Philip Helger
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_COPY_NEEDED
-
Constructor Summary
Constructors Constructor Description MessageDigestValue(EMessageDigestAlgorithm eAlgorithm, byte[] aDigestBytes)MessageDigestValue(EMessageDigestAlgorithm eAlgorithm, byte[] aDigestBytes, boolean bIsCopyNeeded)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]bytes()static MessageDigestValuecreate(byte[] aBytes, EMessageDigestAlgorithm eAlgorithm)Create a newMessageDigestValueobject based on the passed source byte arraystatic MessageDigestValuecreate(InputStream aIS, EMessageDigestAlgorithm eAlgorithm)Create a newMessageDigestValueobject based on the passed sourceInputStream.booleanequals(Object o)EMessageDigestAlgorithmgetAlgorithm()StringgetHexEncodedDigestString()intgetOffset()inthashCode()booleanisCopy()intsize()StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
-
-
-
Field Detail
-
DEFAULT_COPY_NEEDED
public static final boolean DEFAULT_COPY_NEEDED
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MessageDigestValue
public MessageDigestValue(@Nonnull EMessageDigestAlgorithm eAlgorithm, @Nonnull @Nonempty byte[] aDigestBytes)
-
MessageDigestValue
public MessageDigestValue(@Nonnull EMessageDigestAlgorithm eAlgorithm, @Nonnull @Nonempty byte[] aDigestBytes, boolean bIsCopyNeeded)
-
-
Method Detail
-
getAlgorithm
@Nonnull public EMessageDigestAlgorithm getAlgorithm()
- Returns:
- The message digest algorithm used. Never
null.
-
isCopy
public boolean isCopy()
- Specified by:
isCopyin interfacecom.helger.commons.io.IHasByteArray
-
bytes
@Nonnull @Nonempty @ReturnsMutableObject public byte[] bytes()
- Specified by:
bytesin interfacecom.helger.commons.io.IHasByteArray- Returns:
- The message digest bytes. The length depends on the used algorithm.
Never
null. - Since:
- 9.1.3
-
size
@Nonnegative public int size()
- Specified by:
sizein interfacecom.helger.commons.lang.IHasSize
-
getOffset
@Nonnegative public int getOffset()
- Specified by:
getOffsetin interfacecom.helger.commons.io.IHasByteArray
-
getHexEncodedDigestString
@Nonnull @Nonempty public String getHexEncodedDigestString()
- Returns:
- The hex-encoded String of the message digest bytes. Never
null.
-
create
@Nonnull public static MessageDigestValue create(@Nonnull byte[] aBytes, @Nonnull EMessageDigestAlgorithm eAlgorithm)
Create a newMessageDigestValueobject based on the passed source byte array- Parameters:
aBytes- The byte array to create the hash value from. May not benull.eAlgorithm- The algorithm to be used. May not benull.- Returns:
- Never
null.
-
create
@Nonnull public static MessageDigestValue create(@Nonnull @WillClose InputStream aIS, @Nonnull EMessageDigestAlgorithm eAlgorithm) throws IOException
Create a newMessageDigestValueobject based on the passed sourceInputStream.- Parameters:
aIS- The input stream to read from. May not benull.eAlgorithm- The algorithm to be used. May not benull.- Returns:
- Never
null. - Throws:
IOException- In case reading throws an IOException
-
-