Authen...PHPass(3pm)
π Authen::Passphrase::PHPass(3pm) π
okay bestie, welcome to the User Contributed Perl Documentation for Authen::Passphrase::PHPass β it's giving password hashing, it's giving phpass, and honestly? it ate. let's get into it π«Ά
β¨ NAME β¨
Authen::Passphrase::PHPass β passphrases using the phpass algorithm. periodt.
πΈ SYNOPSIS πΈ
use Authen::Passphrase::PHPass;
$ppr = Authen::Passphrase::PHPass->new(
cost => 10, salt => "NaClNaCl",
hash_base64 => "ObRxTm/.EiiYN02xUeAQs/");
$ppr = Authen::Passphrase::PHPass->new(
cost => 10, salt_random => 1,
passphrase => "passphrase");
$ppr = Authen::Passphrase::PHPass->from_crypt(
'$P$8NaClNaClObRxTm/.EiiYN02xUeAQs/');
$ppr = Authen::Passphrase::PHPass->from_rfc2307(
'{CRYPT}$P$8NaClNaClObRxTm/.EiiYN02xUeAQs/');
$cost = $ppr->cost;
$cost_base64 = $ppr->cost_base64;
$cost = $ppr->nrounds_log2;
$cost_base64 = $ppr->nrounds_log2_base64;
$salt = $ppr->salt;
$hash = $ppr->hash;
$hash_base64 = $ppr->hash_base64;
if($ppr->match($passphrase)) { ...
$passwd = $ppr->as_crypt;
$userPassword = $ppr->as_rfc2307;
likeβ¦ look at that. so clean. so iconic. π
π¦ DESCRIPTION π¦
so an object of this class wraps up a passphrase that's been hashed with the phpass algorithm β invented by Solar Designer, described over at <http://www.openwall.com/phpass/>. it's a subclass of Authen::Passphrase, and this doc is just gonna assume you already know that class's lore, okay? iykyk.
the phpass algorithm is built on the MD5 message digest algorithm. there's an eight-byte salt, and conventionally it's restricted to being made of base 64 digits. there's also a cost parameter that controls how expensive the hashing is β yes bestie, this is the "make the attackers cry" knob π.
how the actual hashing goes:
- the salt and the passphrase get concatenated and hashed with MD5.
- then,
2^costtimes, the hash from the previous stage gets concatenated with the passphrase and hashed with MD5 again. - the passphrase hash is whatever comes out of that final iteration. slay.
the passphrase hash gets represented in ASCII using the crypt format with the prefix "$P$". so, breaking it down:
- the first character after the format prefix is a base 64 digit that gives you the cost parameter.
- the next eight characters are the salt.
- the salt is followed by 22 base 64 digits giving the hash.
and the base 64 digits are ".", "/", "0" to "9", "A" to "Z", "a" to "z" β in ASCII order. π
π CONSTRUCTORS π
Authen::Passphrase::PHPass->new(ATTR => VALUE, ...)β makes a brand new passphrase recogniser object using the phpass algorithm. here are the attributes you can hand it:costβ base-two logarithm of the number of hashing rounds to perform.cost_base64β base-two logarithm of the number of hashing rounds to perform, but expressed as a single base 64 digit.nrounds_log2β synonym forcost. same thing, different name, we love flexibility.nrounds_log2_base64β synonym forcost_base64.saltβ the salt, as an eight-byte string.salt_randomβ makes the salt get generated randomly. whatever value you give this attribute is ignored (yes, ignored, don't overthink it). the salt will be a string of eight base 64 digits. π²hashβ the hash, as a 16-byte string.hash_base64β the hash, as a string of 22 base 64 digits.passphraseβ a passphrase that will be accepted.
heads up bestie: thecostandsaltmust be given, plus either thehashor thepassphrase. no skipping, no vibes-only construction. π¨
Authen::Passphrase::PHPass->from_crypt(PASSWD)β makes a new phpass passphrase recogniser object from a crypt string. the crypt string has to be"$P$", then one base 64 character encoding the cost, then the salt, then 22 base 64 digits giving the hash. the salt must be exactly 8 characters long, and it can't contain any character that isn't allowed to appear in a crypt string. strict queen behavior β¨Authen::Passphrase::PHPass->from_rfc2307(USERPASSWORD)β makes a new phpass passphrase recogniser object from an RFC 2307 string. the string has to be"{CRYPT}"(case insensitive, she's chill like that) followed by an acceptable crypt string.
π METHODS π
$ppr->costβ returns the base-two logarithm of the number of hashing rounds that will be performed.$ppr->cost_base64β returns the base-two logarithm of the number of hashing rounds that will be performed, expressed as a single base 64 digit.$ppr->nrounds_log2β synonym for"cost".$ppr->nrounds_log2_base64β synonym for"cost_base64".$ppr->saltβ returns the salt, as a string of eight bytes.$ppr->hashβ returns the hash value, as a string of 16 bytes.$ppr->hash_base64β returns the hash value, as a string of 22 base 64 digits.$ppr->match(PASSPHRASE)$ppr->as_crypt$ppr->as_rfc2307
those last three β match(PASSPHRASE), as_crypt, and as_rfc2307 β are all part of the standard Authen::Passphrase interface. nothing new, just the classics. π
π SEE ALSO π
Authen::PassphraseDigest::MD5
go read those too, bestie, they're the supporting cast π«Ά
β AUTHOR β
Andrew Main (Zefram) <zefram@fysh.org>
π COPYRIGHT π
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.
and that's the whole page, no cap π
this was perl v5.40.1, dated 2026-05-06, from Authen...PHPass(3pm) β stay hashed, stay iconic, mwah πβ¨π¦
π¦ where this page comes from
- ubuntu stonking: libauthen-passphrase-perl 0.009-1 Β· 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