Record Class Argon2PhcString
java.lang.Object
java.lang.Record
io.micronaut.security.password.argon2.Argon2PhcString
- Record Components:
memory- the memory cost, in kibibytesiterations- the number of iterationsparallelism- the degree of parallelismsalt- the salthash- the hash
@Internal
public record Argon2PhcString(long memory, long iterations, int parallelism, byte[] salt, byte[] hash)
extends Record
An Argon2id hash in the PHC string format:
$argon2id$v=19$m=<memory>,t=<iterations>,p=<parallelism>$<salt>$<hash>.
Parsing is strict. Only Argon2id version 19 is accepted, the parameters must appear in the
order m,t,p as decimals without leading zeros, and the salt and hash must be canonical
unpadded Base64. The optional keyid and data parameters are not supported.
- Since:
- 5.5.0
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intLongest hash, in bytes, allowed by the PHC string format.static final intHighest degree of parallelism allowed by the PHC string format.static final intLongest salt, in bytes, allowed by the PHC string format.static final intLowest memory cost, in kibibytes, that Argon2 accepts for each degree of parallelism.static final intShortest hash, in bytes, allowed by the PHC string format.static final intShortest salt, in bytes, allowed by the PHC string format. -
Constructor Summary
ConstructorsConstructorDescriptionArgon2PhcString(long memory, long iterations, int parallelism, byte[] salt, byte[] hash) Creates an instance of aArgon2PhcStringrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.static Stringformat(int memory, int iterations, int parallelism, byte[] salt, byte[] hash) Formats an Argon2id hash as a PHC string.byte[]hash()Returns the value of thehashrecord component.final inthashCode()Returns a hash code value for this object.longReturns the value of theiterationsrecord component.longmemory()Returns the value of thememoryrecord component.intReturns the value of theparallelismrecord component.static @Nullable Argon2PhcStringParses an Argon2id PHC string.byte[]salt()Returns the value of thesaltrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
MEMORY_PER_LANE
public static final int MEMORY_PER_LANELowest memory cost, in kibibytes, that Argon2 accepts for each degree of parallelism.- See Also:
-
MAX_PARALLELISM
public static final int MAX_PARALLELISMHighest degree of parallelism allowed by the PHC string format.- See Also:
-
MIN_SALT_LENGTH
public static final int MIN_SALT_LENGTHShortest salt, in bytes, allowed by the PHC string format.- See Also:
-
MAX_SALT_LENGTH
public static final int MAX_SALT_LENGTHLongest salt, in bytes, allowed by the PHC string format.- See Also:
-
MIN_HASH_LENGTH
public static final int MIN_HASH_LENGTHShortest hash, in bytes, allowed by the PHC string format.- See Also:
-
MAX_HASH_LENGTH
public static final int MAX_HASH_LENGTHLongest hash, in bytes, allowed by the PHC string format.- See Also:
-
-
Constructor Details
-
Argon2PhcString
public Argon2PhcString(long memory, long iterations, int parallelism, byte[] salt, byte[] hash) Creates an instance of aArgon2PhcStringrecord class.- Parameters:
memory- the value for thememoryrecord componentiterations- the value for theiterationsrecord componentparallelism- the value for theparallelismrecord componentsalt- the value for thesaltrecord componenthash- the value for thehashrecord component
-
-
Method Details
-
parse
Parses an Argon2id PHC string.- Parameters:
encoded- the PHC string- Returns:
- the parsed string, or
nullif it is not a conforming Argon2id PHC string
-
format
Formats an Argon2id hash as a PHC string.- Parameters:
memory- the memory cost, in kibibytesiterations- the number of iterationsparallelism- the degree of parallelismsalt- the salthash- the hash- Returns:
- the PHC string
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
memory
-
iterations
public long iterations()Returns the value of theiterationsrecord component.- Returns:
- the value of the
iterationsrecord component
-
parallelism
public int parallelism()Returns the value of theparallelismrecord component.- Returns:
- the value of the
parallelismrecord component
-
salt
-
hash
-