public class MD5OutputStream
extends java.io.FilterOutputStream
This class produces a 128-bit "fingerprint" or "message digest" for all data written to this stream. It is conjectured that it is computationally infeasible to produce two messages having the same message digest, or to produce any message having a given pre-specified target message digest. The MD5 algorithm is intended for digital signature applications, where a large file must be "compressed" in a secure manner before being encrypted with a private (secret) key under a public-key cryptosystem such as RSA.
For more information see RFC1321.
MD5
,
MD5InputStream
Constructor and Description |
---|
MD5OutputStream(java.io.OutputStream out)
Creates MD5OutputStream
|
Modifier and Type | Method and Description |
---|---|
byte[] |
getHash()
Returns array of bytes representing hash of the stream so far.
|
java.lang.String |
getHashString()
Get a 32-character hex representation representing hash of the stream so far.
|
void |
write(byte[] b,
int off,
int len)
Writes length bytes from the specified byte array starting a
offset off to this output stream.
|
void |
write(int b)
Writes the specified byte to this output stream.
|
public MD5OutputStream(java.io.OutputStream out)
out
- The output streampublic void write(int b) throws java.io.IOException
write
in class java.io.FilterOutputStream
b
- the byte.java.io.IOException
- if an I/O error occurs.public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.FilterOutputStream
b
- the data.off
- the start offset in the data.len
- the number of bytes to write.java.io.IOException
- if an I/O error occurs.public byte[] getHash()
public java.lang.String getHashString()
Copyright (c) 2001-2020 by Stephen Ostermiller