public class HashedBlockOutputStream extends OutputStream
A Hashed block consists of:
The stream of blocks is terminated with a 0 length 0 hash block.
Originally developed for KeePass. A KeePass hash block stream is little endian, i.e. the sequence number and length fields are low order byte first.
| Constructor and Description |
|---|
HashedBlockOutputStream(OutputStream outputStream)
Create a BigEndian Hash Block Output Stream
|
HashedBlockOutputStream(OutputStream outputStream,
boolean littleEndian)
Create a Hash Block Output Stream with choice of endian encoding
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
protected void |
put(byte[] b,
int offset,
int length)
Writes to the internal buffer, and writes to the underlying output stream
as necessary as
BLOCK_SIZE blocks |
protected void |
save()
Saqve the internal buffer to the underlying stream as a hash block
|
void |
write(@NotNull byte[] b,
int offset,
int count) |
void |
write(int i) |
protected void |
writeInt(int value)
Write a 4 byte int value to the underlying stream in appropriate endian format
|
writepublic HashedBlockOutputStream(OutputStream outputStream)
outputStream - the output stream to receive the hash blockspublic HashedBlockOutputStream(OutputStream outputStream, boolean littleEndian)
outputStream - the output stream to receive the hash blockslittleEndian - true to encode in a little endian waypublic void write(int i)
throws IOException
write in class OutputStreamIOExceptionpublic void write(@NotNull
@NotNull byte[] b,
int offset,
int count)
throws IOException
write in class OutputStreamIOExceptionpublic void flush()
throws IOException
flush in interface Flushableflush in class OutputStreamIOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class OutputStreamIOExceptionprotected void put(byte[] b,
int offset,
int length)
throws IOException
BLOCK_SIZE blocksb - the byte array to writeoffset - offset in the byte arraylength - number of bytes to writeIOExceptionprotected void save()
throws IOException
IOExceptionprotected void writeInt(int value)
throws IOException
value - the value to writeIOExceptionCopyright © 2017. All rights reserved.