diff options
author | lpsolit%gmail.com <> | 2005-09-02 06:39:20 +0200 |
---|---|---|
committer | lpsolit%gmail.com <> | 2005-09-02 06:39:20 +0200 |
commit | de1f16178dcae2d517e849e45ee77fd3d636005c (patch) | |
tree | 757461a665f72fa131a8662b2daaff8999b84aa9 /Bugzilla/Util.pm | |
parent | 7ce67eec4fb2c17ee3621b1aad2f99295ed4649f (diff) | |
download | bugzilla-de1f16178dcae2d517e849e45ee77fd3d636005c.tar.gz bugzilla-de1f16178dcae2d517e849e45ee77fd3d636005c.tar.xz |
Bug 304582: Move GenerateRandomPassword() out of globals.pl - Patch by Frédéric Buclin <LpSolit@gmail.com> r=joel a=myk
Diffstat (limited to 'Bugzilla/Util.pm')
-rw-r--r-- | Bugzilla/Util.pm | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/Bugzilla/Util.pm b/Bugzilla/Util.pm index f5084e02c..3a9d6dae7 100644 --- a/Bugzilla/Util.pm +++ b/Bugzilla/Util.pm @@ -23,6 +23,7 @@ # Bradley Baetz <bbaetz@student.usyd.edu.au> # Christopher Aillon <christopher@aillon.com> # Max Kanat-Alexander <mkanat@bugzilla.org> +# Frédéric Buclin <LpSolit@gmail.com> package Bugzilla::Util; @@ -40,7 +41,8 @@ use base qw(Exporter); perform_substs format_time format_time_decimal validate_date file_mod_time is_7bit_clean - bz_crypt validate_email_syntax); + bz_crypt generate_random_password + validate_email_syntax); use Bugzilla::Config; use Bugzilla::Constants; @@ -356,6 +358,11 @@ sub bz_crypt { return $cryptedpassword; } +sub generate_random_password { + my $size = shift || 10; # default to 10 chars if nothing specified + return join("", map{ ('0'..'9','a'..'z','A'..'Z')[rand 62] } (1..$size)); +} + sub validate_email_syntax { my ($addr) = @_; my $match = Param('emailregexp'); @@ -435,6 +442,7 @@ Bugzilla::Util - Generic utility functions for bugzilla # Cryptographic Functions $crypted_password = bz_crypt($password); + $new_password = generate_random_password($password_length); # Validation Functions validate_email_syntax($email); @@ -689,6 +697,12 @@ characters of the password to anyone who views the encrypted version. =end undocumented +=item C<generate_random_password($password_length)> + +Returns an alphanumeric string with the specified length +(10 characters by default). Use this function to generate passwords +and tokens. + =back =head2 Validation |