com.kirkwarez.kirkpack.io.eoa.wdysv
Class WDYSVInputStream

java.lang.Object
  extended byjava.io.InputStream
      extended byjava.io.FilterInputStream
          extended bycom.kirkwarez.kirkpack.io.eoa.wdysv.WDYSVInputStream

public class WDYSVInputStream
extends FilterInputStream

This stream streams in MYST V encrypted data and streams out the decrypted data. Since the WDYSV header has the length tag set, one can retrieve the eventual length of the data at any time.

Since:
3.00
Version:
3.00
Author:
Berend "Kirk" Wouda

Field Summary
private static byte[] KEY
          The key.
protected  int length
          The length read from the header.
protected  int total
          The total read from the stream.
static int WDYSV_HEADER
          The WDYSV header.
 
Fields inherited from class java.io.FilterInputStream
in
 
Fields inherited from class java.io.InputStream
 
Constructor Summary
WDYSVInputStream(InputStream input)
          Creates a stream over the given stream.
 
Method Summary
 int available()
          Returns the number of bytes that can be read without blockage.
 int getLength()
          Returns the length of the unencrypted data as indicated by the header of the file.
 int read()
          Reads an unsigned byte and returns it as an int.
 int read(byte[] buffer, int offset, int length)
          Fills the array with bytes from the stream.
protected  void setLength(int length)
          Sets the length of the unencrypted data from the indication by the header of the file.
 long skip(long amount)
          Skips the given amount of bytes, or at least tries to.
 
Methods inherited from class java.io.FilterInputStream
close, mark, markSupported, read, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

length

protected int length
The length read from the header.


total

protected int total
The total read from the stream.


KEY

private static byte[] KEY
The key. Ssh!


WDYSV_HEADER

public static final int WDYSV_HEADER
The WDYSV header.

See Also:
Constant Field Values
Constructor Detail

WDYSVInputStream

public WDYSVInputStream(InputStream input)
                 throws IOException
Creates a stream over the given stream.

Parameters:
input - The stream to read from.
Throws:
IOException - When the given stream does not produce EAO data.
Method Detail

read

public int read()
         throws IOException
Reads an unsigned byte and returns it as an int. When the length indicated by the file is reached, no more bytes are read in.

Returns:
The byte as an int.
Throws:
IOException - When boo boo goes doo doo.
See Also:
InputStream.read()

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws IOException
Fills the array with bytes from the stream. Not necessarily completely though, but with at least one. When the length indicated by the file is reached, no more bytes are read in.

Parameters:
buffer - The buffer to read the data into.
offset - The starting offset.
length - The amount of bytes to read.
Returns:
The amount of bytes actually read.
Throws:
IOException - When boo boo goes doo doo.
See Also:
InputStream.read(byte[], int, int)

skip

public long skip(long amount)
          throws IOException
Skips the given amount of bytes, or at least tries to.

Returns:
The actual amount of bytes skipped.
Throws:
IOException
See Also:
InputStream.read(byte[], int, int), InputStream.skip(long)

available

public int available()
              throws IOException
Returns the number of bytes that can be read without blockage. This version keeps in mind that there is a preset length in the header.

Returns:
The number of bytes that can be read without blockage.
Throws:
IOException
See Also:
InputStream.available()

getLength

public int getLength()
Returns the length of the unencrypted data as indicated by the header of the file.

Returns:
The length of the unencrypted data.

setLength

protected void setLength(int length)
Sets the length of the unencrypted data from the indication by the header of the file.

Parameters:
length - The length of the unencrypted data.