aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Kangas <stefankangas@gmail.com>2010-12-31 00:36:47 +0100
committerStefan Kangas <stefankangas@gmail.com>2010-12-31 00:36:47 +0100
commitc1bf5f074f8c6c079445d836dcdaf7b9bbc911ea (patch)
tree8f10c4c20f6bb0e8fcf9daa78ff4085865e09d9f
parent3bab37d8124cca63999c22a03dfd6f29f2ceb7f6 (diff)
Fix password generation, add missing subroutine
-rwxr-xr-xfripost-mkpass.pl1
-rwxr-xr-xlib/Fripost/Password.pm11
2 files changed, 9 insertions, 3 deletions
diff --git a/fripost-mkpass.pl b/fripost-mkpass.pl
index 3b0c9f7..fba5079 100755
--- a/fripost-mkpass.pl
+++ b/fripost-mkpass.pl
@@ -24,7 +24,6 @@ my $password = mkpasswd(
-minnum => 5,
-minspecial => 3
);
-$user{password} = smd5($password);
# Show the information that will be inserted
say "Generated password: $password";
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> >>