Record Class PasswordHashResult

java.lang.Object
java.lang.Record
co.cryptoservice.sdk.PasswordHashResult
Record Components:
algorithm - password hashing algorithm
hash - the 32-byte Argon2id hash; lowercase hex
params - argon2id parameters; pass them back to verify
phc - the same hash as a PHC string ($argon2id$v=19$m=..,t=..,p=..$salt$hash, unpadded base64 fields)
salt - the random 16-byte salt; lowercase hex

public record PasswordHashResult(String algorithm, String hash, Argon2Params params, String phc, String salt) extends Record
What POST /v2/password/hash answers: hash a password with Argon2id.
  • Constructor Details

    • PasswordHashResult

      public PasswordHashResult(String algorithm, String hash, Argon2Params params, String phc, String salt)
      Creates an instance of a PasswordHashResult record class.
      Parameters:
      algorithm - the value for the algorithm record component
      hash - the value for the hash record component
      params - the value for the params record component
      phc - the value for the phc record component
      salt - the value for the salt record component
  • Method Details

    • hashBytes

      public byte[] hashBytes()
      hash() decoded from hex.
      Returns:
      the bytes, or null when hash is absent
      Throws:
      IllegalArgumentException - when the server sent malformed hex
    • saltBytes

      public byte[] saltBytes()
      salt() decoded from hex.
      Returns:
      the bytes, or null when salt is absent
      Throws:
      IllegalArgumentException - when the server sent malformed hex
    • toString

      public String toString()
      Names the members; values that may be secret (keys, plaintexts, passwords, signatures) are redacted.
      Specified by:
      toString in class Record
      Returns:
      a description safe to log
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • algorithm

      public String algorithm()
      Returns the value of the algorithm record component.
      Returns:
      the value of the algorithm record component
    • hash

      public String hash()
      Returns the value of the hash record component.
      Returns:
      the value of the hash record component
    • params

      public Argon2Params params()
      Returns the value of the params record component.
      Returns:
      the value of the params record component
    • phc

      public String phc()
      Returns the value of the phc record component.
      Returns:
      the value of the phc record component
    • salt

      public String salt()
      Returns the value of the salt record component.
      Returns:
      the value of the salt record component