All Packages Class Hierarchy This Package Previous Next Index
Class IS.hi.logir.cryptonite.Data
java.lang.Object
|
+----IS.hi.logir.cryptonite.Data
- public class Data
- extends Object
- implements Serializable, Fingerprintable
The Data class is hods an ordered pair (n,buf), where buf is an array of
bytes containing data in the first n bytes. This is used to return data
from methods where we want to re-use arrays if possible and only
re-allocate them if we need to them.
For example, the call Key.encrypt(buf, dest) takes a parameter
of type Data in dest and if the encrypted array is no larger than dest.buf,
it just writes the encrypted data to it. Otherwise dest.buf is
enlarged. In either case, dest.n is the actual number of bytes of
encrypted data.
- Author:
- Logi Ragnarsson (logir@hi.is)
- See Also:
- Key
-
buf
-
-
EMPTY
-
-
n
-
-
Data()
- Create a new empty Data object.
-
Data(byte[])
- Create a new data object around the bytes in buffer.
-
Data(byte[], int)
- Create a new data object around the first m bytes
in buffer.
-
Data(int)
- Create a new empty data object that can hold
m bytes without being enlarged.
-
enlarge(int)
- Make sure that the object can hold at least m bytes.
-
enlargeSafe(int)
- Make sure that the object can hold at least m bytes,
without destroying the data it contains.
-
getFingerprint()
-
-
reallocate(int)
- Reallocate the buffer and make it m bytest large.
-
resizeSafe(int)
- Resize the buffer so it can hold as close to m bytes
as possible without losing data.
n
public int n
buf
public byte buf[]
EMPTY
private static byte EMPTY[]
Data
public Data()
- Create a new empty Data object.
Data
public Data(int m)
- Create a new empty data object that can hold
m bytes without being enlarged.
Data
public Data(byte buffer[])
- Create a new data object around the bytes in buffer.
The buffer must contain at least m bytes.
Data
public Data(byte buffer[],
int m)
- Create a new data object around the first m bytes
in buffer. The buffer must contain at least m bytes.
enlarge
public synchronized void enlarge(int m)
- Make sure that the object can hold at least m bytes.
This clears the object.
enlargeSafe
public synchronized void enlargeSafe(int m)
- Make sure that the object can hold at least m bytes,
without destroying the data it contains.
reallocate
public synchronized void reallocate(int m)
- Reallocate the buffer and make it m bytest large.
This clears the object.
resizeSafe
public synchronized void resizeSafe(int m)
- Resize the buffer so it can hold as close to m bytes
as possible without losing data.
getFingerprint
public Fingerprint getFingerprint()
All Packages Class Hierarchy This Package Previous Next Index