Backend API. Server-side code: this runs in a Codename One backend, not in the app on the device.
public final class Sha256HexPasswordEncoder
- Object
- Sha256HexPasswordEncoder
ImplementsPasswordEncoder
The hexadecimal SHA-256 of a value, unsalted and in one round. Registered as
{sha256}.
This exists to verify values another system stored this way, so that they can be imported without asking every user for new ones: recovery codes, or tokens that are long and random. A single unsalted digest is far too fast for a password a person chose; never encode those with it.
matches(CharSequence, String) compares in constant time and accepts upper
or lower case hexadecimal, and upgradeEncoding(String) is always true.
Constructors
public Sha256HexPasswordEncoder() |
Methods
public String encode(CharSequence rawPassword) | The password as it should be stored: salted and hashed, so encoding one password twice gives two different results. |
public boolean matches(CharSequence rawPassword, String encodedPassword) | Whether rawPassword is the password encodedPassword was made from. |
public boolean upgradeEncoding(String encodedPassword) | Whether encodedPassword should be encoded again for better protection: it was made by an older scheme, or with fewer rounds than this encoder uses now. |
Inherited methods
Constructor details
Sha256HexPasswordEncoder
public Sha256HexPasswordEncoder()Method details
encode
public String encode(CharSequence rawPassword)The password as it should be stored: salted and hashed, so encoding one
password twice gives two different results.
matches
public boolean matches(CharSequence rawPassword, String encodedPassword)Whether
rawPassword is the password encodedPassword was made from.upgradeEncoding
public boolean upgradeEncoding(String encodedPassword)Whether
encodedPassword should be encoded again for better protection:
it was made by an older scheme, or with fewer rounds than this encoder
uses now.