Class Nonce

java.lang.Object
org.drasyl.handler.remote.protocol.Nonce

@UnstableApi public class Nonce extends Object
A RemoteMessage is uniquely identified by its NONCE_LENGTH bytes long nonce.

This is an immutable object.

  • Field Details

    • PSEUDORANDOM_NONCE

      public static final boolean PSEUDORANDOM_NONCE
    • NONCE_LENGTH

      public static final int NONCE_LENGTH
      See Also:
  • Method Details

    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toByteArray

      public byte[] toByteArray()
    • toImmutableByteArray

      public ImmutableByteArray toImmutableByteArray()
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • writeTo

      public void writeTo(io.netty.buffer.ByteBuf out)
      Writes this nonce to the buffer out.
      Parameters:
      out - writes this nonce to the given buffer
    • randomNonce

      public static Nonce randomNonce()
      Static factory to retrieve a randomly generated Nonce.
      Returns:
      A randomly generated Nonce
    • isValidNonce

      public static boolean isValidNonce(byte[] bytes)
      Checks if bytes is a valid value.
      Parameters:
      bytes - string to be validated
      Returns:
      true if valid. Otherwise false
    • of

      public static Nonce of(@NonNull byte[] bytes)
      Throws:
      NullPointerException - if bytes is null
    • of

      public static Nonce of(@NonNull ImmutableByteArray bytes)
      Throws:
      NullPointerException - if bytes is null
    • of

      public static Nonce of(@NonNull String bytes)
      Throws:
      NullPointerException - if bytes is null