REGEXVAULTv2.0
Security/Password Formats
Verified Safe

MD5 Hash (Deprecated — Detection Only) Regex for Go

/^[a-f0-9]{32}$/i

What this pattern does

This page provides a lightweight, single-purpose regular expression for matching md5 hash (deprecated — detection only), ported and verified for Go. In security-sensitive code, using an unverified regex can open the door to both false positives and denial-of-service attacks. The snippet below is ready to drop into your Go project — whether you're validating in a Gin handler, a gRPC service, or a command-line tool.

Go Implementation

Go
// MD5 Hash (Deprecated — Detection Only)
// ReDoS-safe | RegexVault — Security > Password Formats

package validation

import "regexp"

var md5HashDeprecatedDetectionOnlyRe = regexp.MustCompile(`^[a-f0-9]{32}$`)

func ValidateMd5HashDeprecatedDetectionOnly(s string) bool {
    return md5HashDeprecatedDetectionOnlyRe.MatchString(s)
}

// Example
// fmt.Println(ValidateMd5HashDeprecatedDetectionOnly("d41d8cd98f00b204e9800998ecf8427e")) // true

Test Cases

Matches (Valid)
Rejects (Invalid)
d41d8cd98f00b204e9800998ecf8427ed41d8cd98f00b204e9800998ecf8427
098f6bcd4621d373cade4e832627b4f6d41d8cd98f00b204e9800998ecf8427eX
ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ

When to use this pattern

This pattern is drawn from the Security > Password Formats category and carries a ReDoS-safe certification. That matters for Go developers because Go's RE2 engine is inherently safe from catastrophic backtracking, but this pattern has been additionally verified for correctness. RegexVault audits patterns against known backtracking attack vectors, ensuring you have the necessary context before using this regex in a high-stakes production environment.

Common Pitfalls

MD5 hashes of passwords can be cracked in milliseconds with GPU rainbow tables for passwords under 10 characters. A database of MD5-hashed passwords is effectively a plaintext database for short passwords.

Technical Notes

MD5 is cryptographically broken — collision attacks are trivial, preimage attacks are feasible. Never use MD5 for password hashing or security purposes. Use only for checksums where collision resistance is not required (e.g., non-security file deduplication). Include this pattern only for detection/migration purposes.

Have a pattern that belongs in the vault?

Submit it for review — community-verified patterns get credited to your GitHub handle. Free submissions join the queue. Priority review available for $15.

Submit a Pattern