Package org.apache.sshd.common.digest
Class BaseDigest
- java.lang.Object
-
- org.apache.sshd.common.digest.BaseDigest
-
- All Implemented Interfaces:
java.lang.Comparable<Digest>
,AlgorithmNameProvider
,Digest
,DigestInformation
public class BaseDigest extends java.lang.Object implements Digest
Base class for Digest algorithms based on the JCE provider.
-
-
Constructor Summary
Constructors Constructor Description BaseDigest(java.lang.String algorithm, int bsize)
Create a new digest using the given algorithm and block size.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(Digest that)
byte[]
digest()
boolean
equals(java.lang.Object obj)
java.lang.String
getAlgorithm()
int
getBlockSize()
protected java.security.MessageDigest
getMessageDigest()
int
hashCode()
void
init()
java.lang.String
toString()
void
update(byte[] data)
void
update(byte[] data, int start, int len)
-
-
-
Constructor Detail
-
BaseDigest
public BaseDigest(java.lang.String algorithm, int bsize)
Create a new digest using the given algorithm and block size. The initialization and creation of the underlyingMessageDigest
object will be done in theinit()
method.- Parameters:
algorithm
- the JCE algorithm to use for this digestbsize
- the block size of this digest
-
-
Method Detail
-
getAlgorithm
public final java.lang.String getAlgorithm()
- Specified by:
getAlgorithm
in interfaceAlgorithmNameProvider
-
getBlockSize
public int getBlockSize()
- Specified by:
getBlockSize
in interfaceDigestInformation
- Returns:
- The number of bytes in the digest's output
-
init
public void init() throws java.lang.Exception
-
update
public void update(byte[] data) throws java.lang.Exception
-
update
public void update(byte[] data, int start, int len) throws java.lang.Exception
-
getMessageDigest
protected java.security.MessageDigest getMessageDigest()
- Returns:
- The current
MessageDigest
- may benull
ifinit()
not called
-
digest
public byte[] digest() throws java.lang.Exception
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
compareTo
public int compareTo(Digest that)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Digest>
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-