java.lang.Object
net.i2p.data.SessionTag
32 bytes, usually of random data.
Not recommended for external use, subject to change.
As of 0.9.44, does NOT extend SimpleDataStructure, to save space.
Field Summary
Modifier and TypeFieldDescriptionprivate final intHash of the tag, computed once at construction.private final byte[]The 32 bytes of the tag.static final intTag length in bytes (32).Constructor Summary
ConstructorsConstructorDescriptionInstantiate the data array and fill it with random data.SessionTag(boolean create) Instantiate the data array and fill it with random data.SessionTag(byte[] val) Create a tag over a caller-supplied value, which must be exactly BYTE_LENGTH bytes long.Method Summary
All MethodsModifier and TypeMethodDescriptionbooleanCompares this session tag with another object for equality.byte[]getData()Session tag data.inthashCode()SessionTags are generated both locally and by peers, in quantity, and are used as keys in several datastructures (see TransientSessionKeyManager), so we use a secure hashCode function.intlength()Length of the session tag.toString()Returns a string representation of this session tag.
Field Details
BYTE_LENGTH
_cachedHashCode
private final int _cachedHashCodeHash of the tag, computed once at construction._data
private final byte[] _dataThe 32 bytes of the tag.
Constructor Details
SessionTag
public SessionTag()Instantiate the data array and fill it with random data.SessionTag
public SessionTag(boolean create) Instantiate the data array and fill it with random data.- Parameters:
create- ignored as of 0.9.44, assumed true
SessionTag
public SessionTag(byte[] val) Create a tag over a caller-supplied value, which must be exactly BYTE_LENGTH bytes long.- Parameters:
val- as of 0.9.44, non-null
Method Details
getData
public byte[] getData()Session tag data.- Returns:
- a copy of the internal data to prevent callers from mutating the tag
length
public int length()Length of the session tag.- Returns:
- 32, the tag length in bytes
hashCode
equals
toString