java.lang.Object
com.aoapps.security.Identifier
- All Implemented Interfaces:
Serializable
,Comparable<Identifier>
A 128-bit random identifier internally stored as two long values.
- Author:
- AO Industries, Inc.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new, randomIdentifier
using a defaultSecureRandom
instance, which is not a strong instance to avoid blocking.Identifier
(long hi, long lo) Identifier
(String encoded) Identifier
(SecureRandom secureRandom) Creates a new, randomIdentifier
using the providedSecureRandom
source.Identifier
(Random random) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionint
compareTo
(Identifier other) Unsigned ordering.boolean
equals
(Identifier other) Performs comparisons in length-constant time.boolean
long
getHi()
long
getLo()
int
hashCode()
static void
char[]
The external representation is a string of characters encoded in base #BASE, with the first #NUM_CHARACTERS characters for "hi" and the last #NUM_CHARACTERS characters for "lo".toString()
The external representation is a string of characters encoded in base #BASE, with the first #NUM_CHARACTERS characters for "hi" and the last #NUM_CHARACTERS characters for "lo".static Identifier
-
Constructor Details
-
Identifier
public Identifier()Creates a new, randomIdentifier
using a defaultSecureRandom
instance, which is not a strong instance to avoid blocking. -
Identifier
Deprecated.Please useSecureRandom
. This method will stay, but will remain deprecated since it should only be used after careful consideration.Creates a new, randomIdentifier
using the providedRandom
source. -
Identifier
Creates a new, randomIdentifier
using the providedSecureRandom
source. -
Identifier
public Identifier(long hi, long lo) -
Identifier
- Throws:
IllegalArgumentException
- See Also:
-
-
Method Details
-
valueOf
- Throws:
IllegalArgumentException
- See Also:
-
equals
-
equals
Performs comparisons in length-constant time. https://crackstation.net/hashing-security.htm -
hashCode
public int hashCode() -
toCharArray
public char[] toCharArray()The external representation is a string of characters encoded in base #BASE, with the first #NUM_CHARACTERS characters for "hi" and the last #NUM_CHARACTERS characters for "lo". -
toString
The external representation is a string of characters encoded in base #BASE, with the first #NUM_CHARACTERS characters for "hi" and the last #NUM_CHARACTERS characters for "lo". -
compareTo
Unsigned ordering.- Specified by:
compareTo
in interfaceComparable<Identifier>
-
getHi
public long getHi() -
getLo
public long getLo() -
main
-
SecureRandom
.