Authen...MySQL41(3pm)

πŸ’– Authen...MySQL41 πŸ’–

okay bestie, so this is a page from the User Contributed Perl Documentation β€” you know, the lil manual you get for Authen::Passphrase::MySQL41 (it's a 3pm page, obviously πŸ’…). Sit down, grab a strawberry πŸ“, and let's get into it.


✨ NAME ✨

Authen::Passphrase::MySQL41 β€” passphrases using the MySQL v4.1 algorithm. yes, that MySQL. the old-ish one. iconic behavior tbh.


🌸 SYNOPSIS 🌸

use Authen::Passphrase::MySQL41;

$ppr = Authen::Passphrase::MySQL41->new(
        hash_hex => "9CD12C48C4C5DD62914B".
                    "3FABB93131746E9E9115");

$ppr = Authen::Passphrase::MySQL41->new(
        passphrase => "passphrase");

$hash = $ppr->hash;
$hash_hex = $ppr->hash_hex;

if($ppr->match($passphrase)) { ...

look at that. two ways in, three ways out. we love a flexible object 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so an object of this class is like a lil container that encapsulates a passphrase hashed using the algorithm MySQL has been using since version 4.1. she's a subclass of Authen::Passphrase, and ngl this doc just assumes you already know the Authen::Passphrase documentation. so go read that first, bestie, fr fr.

the MySQL v4.1 hash scheme? it's based on the SHA-1 digest algorithm. here's the tea: the passphrase gets hashed with SHA-1 first, and then the output of that stage gets hashed with SHA-1 again. the final hash is the output of the second SHA-1. and no salt. none. zero. nada. πŸ’€

in MySQL, the hash is represented as a "*" followed by 40 uppercase hexadecimal digits.

⚠️ okay so the lack of salt is a genuine weakness in this scheme. like, lowkey a security problem. salted SHA-1 is a better scheme β€” go look at Authen::Passphrase::SaltedDigest. protect yourself bestie πŸ’œ

πŸŽ€ CONSTRUCTOR πŸŽ€

  • Authen::Passphrase::MySQL41->new(ATTR => VALUE, ...) β€” generates a brand new passphrase recogniser object using the MySQL v4.1 algorithm. slay. you can pass these attributes:
    • hash β€” the hash, as a string of 20 bytes.
    • hash_hex β€” the hash, as a string of 40 hexadecimal digits.
    • passphrase β€” a passphrase that will be accepted.
either the hash or the passphrase must be given. not optional, she needs something to work with πŸ™ˆ

πŸ’… METHODS πŸ’…

  • $ppr->hash β€” returns the hash value, as a string of 20 bytes.
  • $ppr->hash_hex β€” returns the hash value, as a string of 40 uppercase hexadecimal digits. uppercase!! the glow-up is in the caps ⭐
  • $ppr->match(PASSPHRASE) β€” checks if that passphrase matches. heads up: this method is part of the standard Authen::Passphrase interface, so it's not a special MySQL-only thing β€” it's the ✨canonical✨ way in. iykyk.

πŸ‘€ SEE ALSO πŸ‘€

  • Authen::Passphrase
  • Digest::SHA

go read those too, they're the supporting cast and they ate πŸ”₯


πŸ‘‘ AUTHOR πŸ‘‘

Andrew Main (Zefram) <zefram@fysh.org> β€” absolute legend, we stan.


Copyright (C) 2006, 2007, 2009, 2010, 2012 Andrew Main (Zefram) <zefram@fysh.org>


πŸ’– LICENSE πŸ’–

this module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. go wild, that's the whole vibe 🧚


and that's the page!! a little perl v5.40.1 moment, dated 2026-05-06, and it's one of those Authen...MySQL41(3pm) situations β€” anyway bestie, hydrate, salt your hashes, and go forth and match 🫢✨

πŸ“¦ where this page comes from