From 9d4c2b6ce82aa8c6852177b5f77a82f604f0c2f5 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Thu, 20 Jun 2013 09:07:01 +0200 Subject: [PATCH] Modul Digest::SHA1 auch nicht mehr als Fallback versuchen MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Wird schlicht nicht mehr benötigt: Digest::SHA kam mit Perl 5.9.3 in Core, und wir setzen 5.10.1 voraus. --- SL/Auth/Password.pm | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/SL/Auth/Password.pm b/SL/Auth/Password.pm index ec6fc72ec..5ae75eac5 100644 --- a/SL/Auth/Password.pm +++ b/SL/Auth/Password.pm @@ -3,45 +3,23 @@ package SL::Auth::Password; use strict; use Carp; +use Digest::MD5 (); +use Digest::SHA (); sub hash { my ($class, %params) = @_; - if (!$params{algorithm}) { - $params{algorithm} = 'SHA256S'; - $params{fallback_algorithm} = 'MD5'; - } - + $params{algorithm} ||= 'SHA256S'; my $salt = $params{algorithm} =~ m/S$/ ? $params{login} : ''; if ($params{algorithm} =~ m/^SHA256/) { - if (eval { require Digest::SHA; 1 }) { - return '{' . $params{algorithm} . '}' . Digest::SHA::sha256_hex($salt . $params{password}); - - } elsif ($params{fallback_algorithm}) { - return $class->hash(%params, algorithm => $params{fallback_algorithm}); - - } else { - die 'Digest::SHA is not available'; - } + return '{' . $params{algorithm} . '}' . Digest::SHA::sha256_hex($salt . $params{password}); } elsif ($params{algorithm} =~ m/^SHA1/) { - if (eval { require Digest::SHA; 1 }) { - return '{' . $params{algorithm} . '}' . Digest::SHA::sha1_hex($salt . $params{password}); - - } elsif (eval { require Digest::SHA1; 1 }) { - return '{' . $params{algorithm} . '}' . Digest::SHA1::sha1_hex($salt . $params{password}); - - } elsif ($params{fallback_algorithm}) { - return $class->hash(%params, algorithm => $params{fallback_algorithm}); - - } else { - die 'Neither Digest::SHA nor Digest::SHA1 is available'; - } + return '{' . $params{algorithm} . '}' . Digest::SHA::sha1_hex($salt . $params{password}); } elsif ($params{algorithm} =~ m/^MD5/) { - require Digest::MD5; return '{' . $params{algorithm} . '}' . Digest::MD5::md5_hex($salt . $params{password}); } elsif ($params{algorithm} eq 'CRYPT') { -- 2.20.1