bcrypt Password Hash
Match bcrypt password hashes in their canonical $2a$/$2b$/$2y$ prefixed format.
Try it in RegexPro →Available in
JavaScript / ECMAScript code
const re = new RegExp("\\$2[abxy]?\\$\\d{2}\\$[./A-Za-z0-9]{53}", "g");
const input = "$2a$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUW";
const matches = [...input.matchAll(re)];
console.log(matches.map(m => m[0]));Uses `String.prototype.matchAll` for global iteration (Node 12+ / all modern browsers).
Python (re) code
import re
pattern = re.compile(r"\$2[abxy]?\$\d{2}\$[./A-Za-z0-9]{53}")
input_text = "$2a$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUW"
for m in pattern.finditer(input_text):
print(m.group(0))Stdlib `re` module — no third-party dependency. Works on Python 3.6+.
Go (RE2) code
package main
import (
"fmt"
"regexp"
)
func main() {
re := regexp.MustCompile(`\$2[abxy]?\$\d{2}\$[./A-Za-z0-9]{53}`)
input := `$2a$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUW`
for _, match := range re.FindAllString(input, -1) {
fmt.Println(match)
}
}Uses `regexp.MustCompile` (panics on bad patterns at startup) and `FindAllString` for all matches.
Pattern
\$2[abxy]?\$\d{2}\$[./A-Za-z0-9]{53} (flags: g)Raw source: \$2[abxy]?\$\d{2}\$[./A-Za-z0-9]{53}
How it works
Examples
Input
$2a$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUWMatches
$2a$12$R9h/cIPz0gi.URNNX3kh2OPST9/PgBkqquzi.Ss7KIUgO2t0jWMUW
Common use cases
- •Detecting leaked hashes in dumps
- •Secret scanning in configs
- •Security audit of DB exports
- •Migration tooling between hash formats
Related patterns
Strong Password
SecurityEnforce strong passwords: min 8 chars, at least one lowercase, uppercase, digit, and special character.
GitHub Personal Access Token
SecurityMatch GitHub Personal Access Tokens (classic + fine-grained) and OAuth tokens by their `ghX_` prefix.
SSH Public Key
SecurityMatch SSH public keys in OpenSSH `authorized_keys` format, including the optional comment field.
AWS Access Key ID
SecurityMatch AWS access key IDs (both long-term AKIA and temporary ASIA prefixes).