From c1bf5f074f8c6c079445d836dcdaf7b9bbc911ea Mon Sep 17 00:00:00 2001 From: Stefan Kangas Date: Fri, 31 Dec 2010 00:36:47 +0100 Subject: Fix password generation, add missing subroutine --- lib/Fripost/Password.pm | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/Fripost/Password.pm b/lib/Fripost/Password.pm index eb5ad7e..0205799 100755 --- a/lib/Fripost/Password.pm +++ b/lib/Fripost/Password.pm @@ -17,7 +17,7 @@ use Digest::MD5; use Exporter; use MIME::Base64; -our @EXPORT = qw/smd5 make_salt/ +our @EXPORT = qw/smd5 make_salt/; sub smd5 { my $pw = shift; @@ -25,7 +25,6 @@ sub smd5 { return "{SMD5}" . pad_base64( MIME::Base64::encode( Digest::MD5::md5( $pw . $salt ) . $salt, '' ) ); } - sub make_salt { my $len = 8 + int( rand(8) ); my @bytes = (); @@ -35,6 +34,14 @@ sub make_salt { return pack( 'C*', @bytes ); } +sub pad_base64 { + my $b64_digest = shift; + while ( length($b64_digest) % 4 ) { + $b64_digest .= '='; + } + return $b64_digest; +} + =head1 AUTHOR Stefan Kangas C<< >> -- cgit v1.2.3