diff options
Diffstat (limited to 'lib/Fripost')
-rwxr-xr-x | lib/Fripost/Password.pm | 11 |
1 files changed, 9 insertions, 2 deletions
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<< <skangas at skangas.se> >> |