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, randomIdentifierusing a defaultSecureRandominstance, which is not a strong instance to avoid blocking.Identifier(long hi, long lo) Identifier(String encoded) Identifier(SecureRandom secureRandom) Creates a new, randomIdentifierusing the providedSecureRandomsource.Identifier(Random random) Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(Identifier other) Unsigned ordering.booleanequals(Identifier other) Performs comparisons in length-constant time.booleanlonggetHi()longgetLo()inthashCode()static voidchar[]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, randomIdentifierusing a defaultSecureRandominstance, 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, randomIdentifierusing the providedRandomsource. -
Identifier
Creates a new, randomIdentifierusing the providedSecureRandomsource. -
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:
compareToin interfaceComparable<Identifier>
-
getHi
public long getHi() -
getLo
public long getLo() -
main
-

SecureRandom.