Skip to content

Commit ab73d5e

Browse files
Merge pull request #8 from oven-sh/dylan/handle-bcrypt-version-prefixes
omit version prefixes from bcrypt verify
2 parents fe6c443 + b95a4b7 commit ab73d5e

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/std/crypto/bcrypt.zig

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,10 @@ const CryptFormatHasher = struct {
742742
.rounds_log = rounds_log,
743743
.silently_truncate_password = silently_truncate_password,
744744
});
745-
if (!mem.eql(u8, wanted_s[0..], str[0..])) return HasherError.PasswordVerificationFailed;
745+
746+
// From [3..] to skip comparing version prefix. The input can have any version,
747+
// and `strHashInternal` always prefixes with the current version $2b.
748+
if (!mem.eql(u8, wanted_s[3..], str[3..])) return HasherError.PasswordVerificationFailed;
746749
}
747750
};
748751

0 commit comments

Comments
 (0)