Back to cheatsheets
Cryptography
Hash Type Identification
Detect hash types by length and format patterns — MD5, SHA-1, SHA-256, bcrypt, Argon2, and more.
What you'll learn
- Identify by length and pattern
How to use these snippets
- Click the Copy button next to any snippet to copy it to your clipboard.
- Paste the code into your project, IDE, or terminal.
- Replace placeholder values (like
example.comoryour-secret) with your actual data. - Review the code comments for important security notes and caveats.
- Try the interactive related tool to see the concept in action.
Code Snippets
Copy-paste code snippets
1 ready-to-use snippets for hash type identification. Click copy and paste into your project.
Identify by length and pattern
function identifyHash(hash) {
const h = hash.trim();
const results = [];
// By length
const byLength = {
32: 'MD5',
40: 'SHA-1',
56: 'SHA-224',
64: 'SHA-256',
96: 'SHA-384',
128: 'SHA-512',
};
if (byLength[h.length] && /^[0-9a-f]+$/i.test(h)) {
results.push({ type: byLength[h.length], confidence: 'high' });
}
// By format
if (/^\$2[abxy]\$\d{2}\$/.test(h))
results.push({ type: 'bcrypt', confidence: 'high' });
if (/^\$argon2[id]?\$/.test(h))
results.push({ type: 'Argon2', confidence: 'high' });
if (/^[0-9a-f]{32}:[0-9a-f]+$/i.test(h))
results.push({ type: 'NTLM (hash:salt)', confidence: 'medium' });
return results;
}
Tool
Related ShieldX tool
Try this concept hands-on with the interactive tool.
100% Free · No signup · No cost
Generate something unguessable right now
148 bits of entropy, a crack-time estimate you can trust, and a clipboard that clears itself after 30 seconds.
Part of the Toolly ecosystem · secure.toolly.site