Class Sha256HexPasswordEncoder
java.lang.Object
com.codename1.backend.security.crypto.Sha256HexPasswordEncoder
- All Implemented Interfaces:
PasswordEncoder
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.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionencode(CharSequence rawPassword) The password as it should be stored: salted and hashed, so encoding one password twice gives two different results.booleanmatches(CharSequence rawPassword, String encodedPassword) WhetherrawPasswordis the passwordencodedPasswordwas made from.booleanupgradeEncoding(String encodedPassword) WhetherencodedPasswordshould be encoded again for better protection: it was made by an older scheme, or with fewer rounds than this encoder uses now.
-
Constructor Details
-
Sha256HexPasswordEncoder
public Sha256HexPasswordEncoder()
-
-
Method Details
-
encode
Description copied from interface:PasswordEncoderThe password as it should be stored: salted and hashed, so encoding one password twice gives two different results.- Specified by:
encodein interfacePasswordEncoder
-
matches
Description copied from interface:PasswordEncoderWhetherrawPasswordis the passwordencodedPasswordwas made from.- Specified by:
matchesin interfacePasswordEncoder
-
upgradeEncoding
Description copied from interface:PasswordEncoderWhetherencodedPasswordshould be encoded again for better protection: it was made by an older scheme, or with fewer rounds than this encoder uses now.- Specified by:
upgradeEncodingin interfacePasswordEncoder
-