Class BCryptHashBean.BCryptParameters

java.lang.Object
org.cryptacular.bean.BCryptHashBean.BCryptParameters
Enclosing class:
BCryptHashBean

public static class BCryptHashBean.BCryptParameters extends Object
Handles encoding and decoding a bcrypt hash of the form $2n$cost$xxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.
  • Constructor Details

    • BCryptParameters

      protected BCryptParameters(String bCryptString)
      Decodes bcrypt parameters from a string.
      Parameters:
      bCryptString - bcrypt hash of the form $2n$cost$xxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy
  • Method Details

    • getVersion

      public String getVersion()
      Returns:
      bcrypt version.
    • getCost

      public int getCost()
      Returns:
      bcrypt cost in the range [4, 31].
    • getSalt

      public byte[] getSalt()
      Returns:
      bcrypt salt.
    • getHash

      public byte[] getHash()
      Returns:
      bcrypt hash.
    • encode

      public String encode()
      Produces an encoded bcrypt hash string from bcrypt parameter data.
      Returns:
      Bcrypt hash of the form $2n$cost$xxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.
    • encode

      public String encode(String hash)
      Produces an encoded bcrypt hash string from bcrypt parameters and a provided hash string.
      Parameters:
      hash - Encoded bcrypt hash bytes; e.g. the value produced from BCryptHashBean.hash(Object...).
      Returns:
      Bcrypt hash of the form $2n$cost$xxxxxxxxxxxxxxxxxxxxxxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy.