Package com.goterl.lazysodium.interfaces
Interface PwHash.Lazy
- All Known Implementing Classes:
LazySodium,LazySodiumJava
- Enclosing interface:
- PwHash
public static interface PwHash.Lazy
-
Method Summary
Modifier and TypeMethodDescriptioncryptoPwHash(String password, int cryptoPwHashLen, byte[] salt, long opsLimit, com.sun.jna.NativeLong memLimit, PwHash.Alg alg) Hashes a given password.cryptoPwHashStr(String password, long opsLimit, com.sun.jna.NativeLong memLimit) Deprecated.cryptoPwHashString(String password, long opsLimit, com.sun.jna.NativeLong memLimit) The most minimal way of hashing a given password to a standard-format string including all used parameters.cryptoPwHashStringNeedsRehash(String hash, long opsLimit, com.sun.jna.NativeLong memLimit) Checks whether the hash needs a rehash.booleancryptoPwHashStringVerify(String hash, String password) Verifies a password represented as a standard-formatted hash, generated bycryptoPwHashString(String, long, NativeLong).cryptoPwHashStrRemoveNulls(String password, long opsLimit, com.sun.jna.NativeLong memLimit) Deprecated.Uses dumb result format; usecryptoPwHashString(String, long, NativeLong)instead.booleancryptoPwHashStrVerify(String hash, String password) Deprecated.Uses dumb hash format; usecryptoPwHashStringVerify(String, String)instead.
-
Method Details
-
cryptoPwHash
String cryptoPwHash(String password, int cryptoPwHashLen, byte[] salt, long opsLimit, com.sun.jna.NativeLong memLimit, PwHash.Alg alg) throws SodiumException Hashes a given password.- Parameters:
cryptoPwHashLen- The hash size that you want. Anything betweenPwHash.BYTES_MINandPwHash.BYTES_MAXpassword- The password to hash.salt- A salt to use with the hash, generated randomly.opsLimit- The number of cycles to perform whilst hashing. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.alg- The algorithm to use. Defaults toPwHash.Alg.PWHASH_ALG_ARGON2ID13.- Returns:
- A hash of the password in bytes, encoded to string.
- Throws:
SodiumException- If the password is too short or the opsLimit is not correct.
-
cryptoPwHashString
String cryptoPwHashString(String password, long opsLimit, com.sun.jna.NativeLong memLimit) throws SodiumException The most minimal way of hashing a given password to a standard-format string including all used parameters. We auto-generate the salt and use the default hashing algorithmPwHash.Alg.- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.- Returns:
- The hashed password in a standard format, including all used parameters.
- Throws:
SodiumException- If the password could not be hashed.- See Also:
-
cryptoPwHashStr
@Deprecated String cryptoPwHashStr(String password, long opsLimit, com.sun.jna.NativeLong memLimit) throws SodiumException Deprecated.Uses dumb result format; usecryptoPwHashString(String, long, NativeLong)instead.The most minimal way of hashing a given password to a string including all used parameters. We auto-generate the salt and use the default hashing algorithmPwHash.Alg.- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.- Returns:
- The hashed password represented as a long encoded string, which includes useless null bytes.
- Throws:
SodiumException- If the password could not be hashed.- See Also:
-
cryptoPwHashStrRemoveNulls
@Deprecated String cryptoPwHashStrRemoveNulls(String password, long opsLimit, com.sun.jna.NativeLong memLimit) throws SodiumException Deprecated.Uses dumb result format; usecryptoPwHashString(String, long, NativeLong)instead.Hashes a string to a string representation including the used parameters, and removes all useless null bytes. Uses the hashing algorithmPwHash.Alg.- Parameters:
password- The password string to hash.opsLimit- The number of cycles to perform whilst hashing. BetweenPwHash.OPSLIMIT_MINandPwHash.OPSLIMIT_MAX.memLimit- The amount of memory to use. BetweenPwHash.MEMLIMIT_MINandPwHash.MEMLIMIT_MAX.- Returns:
- The hash and all used parameters represented as a long hexadecimal string.
- Throws:
SodiumException- If the password could not be hashed.- See Also:
-
cryptoPwHashStrVerify
Deprecated.Uses dumb hash format; usecryptoPwHashStringVerify(String, String)instead.Verifies a password represented as a long encoded string generated bycryptoPwHashStr(String, long, NativeLong)orcryptoPwHashStrRemoveNulls(String, long, NativeLong).- Parameters:
hash- The encoded hash generated bycryptoPwHashStr(String, long, NativeLong)orcryptoPwHashStrRemoveNulls(String, long, NativeLong)password- The password.- Returns:
- True if the password matches the hash, false otherwise.
-
cryptoPwHashStringVerify
Verifies a password represented as a standard-formatted hash, generated bycryptoPwHashString(String, long, NativeLong).- Parameters:
hash- Standard-formatted hashpassword- The password.- Returns:
- True if the password matches the hash, false otherwise.
-
cryptoPwHashStringNeedsRehash
PwHash.NeedsRehashResult cryptoPwHashStringNeedsRehash(String hash, long opsLimit, com.sun.jna.NativeLong memLimit) Checks whether the hash needs a rehash.- Parameters:
hash- Standard-formatted hash generated bycryptoPwHashString(String, long, NativeLong).opsLimit- The operations limit which should be used.memLimit- The memory limit which should be used.- Returns:
- Whether the hash should be rehashed.
-
cryptoPwHashString(String, long, NativeLong)instead.