Package com.mku.salmon
Class Header
java.lang.Object
com.mku.salmon.Header
Header embedded within the AesStream. Header contains nonce and other information for
decrypting the stream.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintGet the chunk size.byte[]Get the raw header data.byte[]Get the magic bytesbyte[]getNonce()Get the nonce.byteGet the Salmon format versionstatic HeaderreadHeaderData(RandomAccessStream stream) Parse the header data from the streamvoidsetChunkSize(int chunkSize) Set the header chunk sizevoidsetNonce(byte[] nonce) Set the nonce to be used.voidsetVersion(byte version) Set the Salmon format versionstatic HeaderwriteHeader(RandomAccessStream stream, byte[] nonce, int chunkSize) Write header data to the stream
-
Field Details
-
HEADER_LENGTH
public static final long HEADER_LENGTHHeader length- See Also:
-
-
Constructor Details
-
Header
public Header(byte[] headerData) Initialize the header with data- Parameters:
headerData- The header data
-
-
Method Details
-
getNonce
public byte[] getNonce()Get the nonce.- Returns:
- The nonce
-
getChunkSize
public int getChunkSize()Get the chunk size.- Returns:
- Chunk size
-
getHeaderData
public byte[] getHeaderData()Get the raw header data.- Returns:
- Header data
-
getVersion
public byte getVersion()Get the Salmon format version- Returns:
- The format version
-
getMagicBytes
public byte[] getMagicBytes()Get the magic bytes- Returns:
- Magic bytes
-
readHeaderData
Parse the header data from the stream- Parameters:
stream- The stream.- Returns:
- The header data.
- Throws:
IOException- Thrown if there is an IO error.
-
writeHeader
public static Header writeHeader(RandomAccessStream stream, byte[] nonce, int chunkSize) throws IOException Write header data to the stream- Parameters:
stream- The stream to write tononce- The noncechunkSize- The chunk size- Returns:
- The header
- Throws:
IOException- If an error occurs
-
setChunkSize
public void setChunkSize(int chunkSize) Set the header chunk size- Parameters:
chunkSize- The chunk size
-
setVersion
public void setVersion(byte version) Set the Salmon format version- Parameters:
version- The format version
-
setNonce
public void setNonce(byte[] nonce) Set the nonce to be used.- Parameters:
nonce- The nonce
-