pub struct BetterAuthScrypt;Expand description
Better Auth’s password hashes, as @better-auth/utils/password writes them:
"<salt>:<key>", where the salt is 16 random bytes in lowercase hex and the key is
scrypt (N = 16384, r = 16, p = 1, 64 bytes) of the NFKC-normalized password, salted with
the salt’s hex string as UTF-8 (not the 16 bytes it encodes), in lowercase hex.
New hashes are written in the same format and PasswordHasher::needs_rehash is always
false, so a Better Auth app on the same database keeps verifying every password, and
rolling back to it loses nobody.
Each hash takes BetterAuthScrypt::MEMORY_BYTES (32 MiB), against argon2id’s 19 MiB,
so cap how many run at once with EmailPassword::max_concurrent_hashes;
BetterAuthCompat does. It’s weaker than fastauth’s default argon2id: use it only
while a Better Auth app shares the database.
Implementations§
Source§impl BetterAuthScrypt
impl BetterAuthScrypt
Sourcepub const MEMORY_BYTES: usize
pub const MEMORY_BYTES: usize
scrypt’s working memory per hash: 128 · N · r bytes, 32 MiB.
Sourcepub fn hash_with_salt(password: &str, salt: &str) -> String
pub fn hash_with_salt(password: &str, salt: &str) -> String
The hash of password with this salt. Better Auth’s salts are 32 lowercase hex
characters; PasswordHasher::hash makes a random one.
Trait Implementations§
Source§impl Clone for BetterAuthScrypt
impl Clone for BetterAuthScrypt
impl Copy for BetterAuthScrypt
Source§impl Debug for BetterAuthScrypt
impl Debug for BetterAuthScrypt
Source§impl Default for BetterAuthScrypt
impl Default for BetterAuthScrypt
Source§impl PasswordHasher for BetterAuthScrypt
impl PasswordHasher for BetterAuthScrypt
Source§fn verify(&self, password: &str, hash: &str) -> Result<bool, String>
fn verify(&self, password: &str, hash: &str) -> Result<bool, String>
Like Better Auth: the first two :-separated parts are the salt and the key, and the
key must equal the lowercase hex of the derived key. A hash without both parts is an
error, as it is in Better Auth.