Jifty:...ltHash(3pm)
β¨ NAME β¨
Jifty::DBI::Filter::SaltHash β it salts and hashes a value before storing it π (yes bestie, that's the whole job, and it does it beautifully)
π§ DESCRIPTION π§
Okay so picture this: you've got a secret. A little value. You want it in the database but you do NOT want it sitting there in plain sight like it's posting its location on main. Enter this filter. πΈ
It generates a random 4-byte salt, and then it MD5s the given value with that salt appended to the value. Then it stores the hash and the salt in the database β and on decode it hands you back a data structure that contains both of them. π
The salt and the hash are both stored in hexadecimal in the database, so you can literally just drop them into a text field. Text field friendly, we love that for us. π
This filter is intended for storing passwords in a database. It's giving security. It's giving "please don't store passwords raw, I'm begging you." π
π encode
Generate a random 4-byte salt, MD5 the value with the salt (encoded to hexadecimal) appended to it, and store both in the database. That's it, that's the whole move. β¨
π² generate_salt
Return a random 4-byte salt value, encoded as an 8-character hex string. Cute little salt, eight characters, freshly generated. π§π¦
π decode
Return an arrayref of (hash, salt), both as hex strings. Two lil values in a list, both hex, both yours. π«Ά
To test whether a provided value is the same one originally encoded, use:
$hash eq md5_hex($value . $salt);
That's the vibe check for passwords, bestie. π
π SEE ALSO π
Jifty::DBI::FilterDigest::MD5
okay that's the whole page, no cap. this one shipped with perl v5.34.0 and it's dated 2022-06-15, so it's been out here salting and hashing since before some of us could drive. iconic behavior honestly. mwah, go salt something responsibly πβ¨
π¦ where this page comes from
- debian bookworm: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libjifty-dbi-perl 0.78-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms