Class OpenSSLDigest
- All Implemented Interfaces:
Digest,ExtendedDigest
- Direct Known Subclasses:
OpenSSLDigest.MD5,OpenSSLDigest.SHA1,OpenSSLDigest.SHA256,OpenSSLDigest.SHA384,OpenSSLDigest.SHA512
public class OpenSSLDigest extends Object implements ExtendedDigest
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classOpenSSLDigest.MD5static classOpenSSLDigest.SHA1static classOpenSSLDigest.SHA256static classOpenSSLDigest.SHA384static classOpenSSLDigest.SHA512 -
Method Summary
Modifier and Type Method Description intdoFinal(byte[] out, int outOff)close the digest, producing the final digest value.protected voidfinalize()Invoked when the garbage collector has detected that this instance is no longer reachable.StringgetAlgorithmName()return the algorithm nameintgetByteLength()Return the size in bytes of the internal buffer the digest applies it's compression function to.intgetDigestSize()return the size, in bytes, of the digest produced by this message digest.voidreset()reset the digest back to it's initial state.voidupdate(byte in)update the message digest with a single byte.voidupdate(byte[] in, int inOff, int len)update the message digest with a block of bytes.
-
Method Details
-
getAlgorithmName
Description copied from interface:Digestreturn the algorithm name- Specified by:
getAlgorithmNamein interfaceDigest- Returns:
- the algorithm name
-
getDigestSize
public int getDigestSize()Description copied from interface:Digestreturn the size, in bytes, of the digest produced by this message digest.- Specified by:
getDigestSizein interfaceDigest- Returns:
- the size, in bytes, of the digest produced by this message digest.
-
getByteLength
public int getByteLength()Description copied from interface:ExtendedDigestReturn the size in bytes of the internal buffer the digest applies it's compression function to.- Specified by:
getByteLengthin interfaceExtendedDigest- Returns:
- byte length of the digests internal buffer.
-
reset
public void reset()Description copied from interface:Digestreset the digest back to it's initial state. -
update
public void update(byte in)Description copied from interface:Digestupdate the message digest with a single byte. -
update
public void update(byte[] in, int inOff, int len)Description copied from interface:Digestupdate the message digest with a block of bytes. -
doFinal
public int doFinal(byte[] out, int outOff)Description copied from interface:Digestclose the digest, producing the final digest value. The doFinal call leaves the digest reset. -
finalize
Description copied from class:ObjectInvoked when the garbage collector has detected that this instance is no longer reachable. The default implementation does nothing, but this method can be overridden to free resources.Note that objects that override
finalizeare significantly more expensive than objects that don't. Finalizers may be run a long time after the object is no longer reachable, depending on memory pressure, so it's a bad idea to rely on them for cleanup. Note also that finalizers are run on a single VM-wide finalizer thread, so doing blocking work in a finalizer is a bad idea. A finalizer is usually only necessary for a class that has a native peer and needs to call a native method to destroy that peer. Even then, it's better to provide an explicitclosemethod (and implementCloseable), and insist that callers manually dispose of instances. This works well for something like files, but less well for something like aBigIntegerwhere typical calling code would have to deal with lots of temporaries. Unfortunately, code that creates lots of temporaries is the worst kind of code from the point of view of the single finalizer thread.If you must use finalizers, consider at least providing your own
ReferenceQueueand having your own thread process that queue.Unlike constructors, finalizers are not automatically chained. You are responsible for calling
super.finalize()yourself.Uncaught exceptions thrown by finalizers are ignored and do not terminate the finalizer thread. See Effective Java Item 7, "Avoid finalizers" for more.
-