java.lang.Object
net.i2p.data.SessionTag

public class SessionTagextends Object
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 Type
    Field
    Description
    private final int
    Hash of the tag, computed once at construction.
    private final byte[]
    The 32 bytes of the tag.
    static final int
    Tag length in bytes (32).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiate 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 Methods
    Modifier and Type
    Method
    Description
    boolean
    Compares this session tag with another object for equality.
    byte[]
    Session tag data.
    int
    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.
    int
    Length of the session tag.
    Returns a string representation of this session tag.

    Methods inherited from class Object

    clone, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • BYTE_LENGTH

      public static final int BYTE_LENGTH
      Tag length in bytes (32).
      See Also:
    • _cachedHashCode

      private final int _cachedHashCode
      Hash of the tag, computed once at construction.
    • _data

      private final byte[] _data
      The 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

      public int hashCode()
      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.
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Compares this session tag with another object for equality.
      Overrides:
      equals in class Object
    • toString

      public String toString()
      Returns a string representation of this session tag.
      Overrides:
      toString in class Object