Class Nonce
- java.lang.Object
-
- org.drasyl.handler.remote.protocol.Nonce
-
public class Nonce extends Object
ARemoteMessage
is uniquely identified by itsNONCE_LENGTH
bytes long nonce.This is an immutable object.
-
-
Field Summary
Fields Modifier and Type Field Description static int
NONCE_LENGTH
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
int
hashCode()
static boolean
isValidNonce(ImmutableByteArray bytes)
Checks ifbytes
is a valid value.static Nonce
of(byte[] bytes)
static Nonce
of(String bytes)
static Nonce
of(ImmutableByteArray bytes)
static Nonce
randomNonce()
Static factory to retrieve a randomly generatedNonce
.byte[]
toByteArray()
ImmutableByteArray
toImmutableByteArray()
String
toString()
-
-
-
Field Detail
-
NONCE_LENGTH
public static final int NONCE_LENGTH
- See Also:
- Constant Field Values
-
-
Method Detail
-
toByteArray
public byte[] toByteArray()
-
toImmutableByteArray
public ImmutableByteArray toImmutableByteArray()
-
randomNonce
public static Nonce randomNonce()
Static factory to retrieve a randomly generatedNonce
.- Returns:
- A randomly generated
Nonce
-
isValidNonce
public static boolean isValidNonce(ImmutableByteArray bytes)
Checks ifbytes
is a valid value.- Parameters:
bytes
- string to be validated- Returns:
true
if valid. Otherwisefalse
-
of
public static Nonce of(@NonNull ImmutableByteArray bytes)
- Throws:
NullPointerException
- ifbytes
isnull
-
of
public static Nonce of(@NonNull byte[] bytes)
- Throws:
NullPointerException
- ifbytes
isnull
-
of
public static Nonce of(@NonNull String bytes)
- Throws:
NullPointerException
- ifbytes
isnull
-
-