Acme-Indigest-Crypt
view release on metacpan or search on metacpan
lib/Acme/Indigest/Crypt.pm view on Meta::CPAN
return Crypt::Passwd::XS::unix_sha512_crypt( $passphrase, join '', @salt );
}
sub parse_salt_string_rounds {
my $self = shift;
my $salt_string = shift;
my $rounds = shift;
defined or $_ = '' for $salt_string;
if ( $salt_string eq '' ) { undef $salt_string }
elsif ( $salt_string eq '$' ) { $salt_string = '' }
defined and $_ = eval "$_" for $rounds;
return ( $salt_string, $rounds );
}
sub digest_multiple {
my $self = shift;
my $input = shift;
my $output = "";
t/01-basic.t view on Meta::CPAN
Xyzzy::10_100_100:$6$rounds=10100100$$new0U2ntlEZPVUPLP3vD/PByGAVVnpnrJ2g9rs28rOmhNQgAah6k5yE/MUj44X5jlyPQ56FoJNIMVQp515vmI/
Xyzzy:salt0:10_100_100:$6$rounds=10100100$salt0$uaUll/x38DR2VZigveBmmuFbKG4ZBYfkt8x1r8pPSyTNQFsUv4/VJOUIgVUqRS5Xj2YlObxBUel.ILD6.zMm50
Alice:::$6$rounds=10000000$$9Ah5580mxlAGTrjHLMSWeoMmMsQwsGdBLzrjISOHj.t6Io6rXFGSzSnNfj6aB.T6JKDbV1sLSbWFeGfVx4jXf0
Bob:::$6$rounds=10000000$$DQXHtFd/jI0R.Bt3ZUiJ8.vOFeNwppdpzNOpBPYO/SkIKDncxwx210AXh/OOcGSMINcnfUfFmC4bYYkJ/DziD0
_END_
next if m/^\s*#/;
next unless my ( $passphrase, $salt_string, $rounds, $want ) = split ':', $_, 4;
( $salt_string, $rounds ) = Acme::Indigest::Crypt->parse_salt_string_rounds( $salt_string, $rounds );
my $have = Acme::Indigest::Crypt->digest( $passphrase, $salt_string, $rounds );
defined or $_ = '(undef)' for $salt_string;
defined or $_ = '' for $rounds;
is( $want, $have, "$passphrase => salt_string:$salt_string rounds:$rounds)" );
}
my ( $input, $output );
$input = <<_END_;
Alice:::Alice plaintext
Alice::10_000_000:Alice plaintext
Alice::10_000_001:Alice plaintext
( run in 1.227 second using v1.01-cache-2.11-cpan-d80b1682f3f )