Class Pbkdf2Sha256PasswordEncoder

java.lang.Object
com.codename1.backend.security.crypto.Pbkdf2Sha256PasswordEncoder
All Implemented Interfaces:
PasswordEncoder

public final class Pbkdf2Sha256PasswordEncoder extends Object implements PasswordEncoder

PBKDF2-HMAC-SHA256 through the runtime's own Crypto.hashPassword(String) and Crypto.verifyPassword(String, String): a random salt per password, and the round count written into the result, so a stored value says how it is to be checked.

pbkdf2$210000$<salt>$<hash>

Registered as {pbkdf2-sha256}, the scheme new passwords get. It is not the format of Spring's Pbkdf2PasswordEncoder; Pbkdf2PasswordEncoder reads that one's {pbkdf2} hashes.

  • Constructor Details

    • Pbkdf2Sha256PasswordEncoder

      public Pbkdf2Sha256PasswordEncoder()
  • Method Details

    • encode

      public String encode(CharSequence rawPassword)
      Description copied from interface: PasswordEncoder
      The password as it should be stored: salted and hashed, so encoding one password twice gives two different results.
      Specified by:
      encode in interface PasswordEncoder
    • matches

      public boolean matches(CharSequence rawPassword, String encodedPassword)
      Description copied from interface: PasswordEncoder
      Whether rawPassword is the password encodedPassword was made from.
      Specified by:
      matches in interface PasswordEncoder
    • upgradeEncoding

      public boolean upgradeEncoding(String encodedPassword)
      True when the stored password was made with fewer rounds than passwords get now.
      Specified by:
      upgradeEncoding in interface PasswordEncoder