public class MacOutputStream
extends java.io.FilterOutputStream
A filtering output stream that computes a MAC (message authentication code) over all data written to the stream.
Constructor and Description |
---|
MacOutputStream(java.io.OutputStream out,
IMac mac)
Creates a new
MacOutputStream . |
Modifier and Type | Method and Description |
---|---|
IMac |
getMac()
Returns the MAC this stream is updating.
|
void |
on(boolean flag)
Turns the digesting state on or off.
|
void |
setMac(IMac mac)
Sets the MAC this stream is updating, which must have already been
initialized.
|
void |
write(byte[] buf,
int off,
int len) |
void |
write(int b) |
public MacOutputStream(java.io.OutputStream out, IMac mac)
Creates a new MacOutputStream
. The stream is initially set
to digest data written, the mac
argument must have already
been initialized, and the mac
argument is not cloned.
out
- The underlying output stream.mac
- The mac instance to use.public IMac getMac()
Returns the MAC this stream is updating.
public void setMac(IMac mac)
Sets the MAC this stream is updating, which must have already been initialized. The argument is not cloned by this method.
mac
- The non-null new MAC.java.lang.NullPointerException
- If the argument is null.public void on(boolean flag)
Turns the digesting state on or off. When off, the MAC will not be updated when data is written to the stream.
flag
- The new digesting state.public void write(int b) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(byte[] buf, int off, int len) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
Copyright © 2025. All rights reserved.