Skip to content

Commit

Permalink
reuse HMAC functionality from Digest::SHA
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 28, 2013
1 parent 565c0e4 commit f7afcd5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
3 changes: 3 additions & 0 deletions Changes
@@ -1,4 +1,7 @@

4.08 2013-05-28
- Improved HMAC-SHA1 performance in Mojo::Util.

4.07 2013-05-26
- Updated jQuery to version 2.0.1.
- Fixed format handling in routes command.
Expand Down
12 changes: 2 additions & 10 deletions lib/Mojo/Util.pm
Expand Up @@ -3,7 +3,7 @@ use Mojo::Base 'Exporter';

use Carp qw(carp croak);
use Digest::MD5 qw(md5 md5_hex);
use Digest::SHA qw(sha1 sha1_hex);
use Digest::SHA qw(hmac_sha1 sha1 sha1_hex);
use Encode 'find_encoding';
use File::Basename 'dirname';
use File::Spec::Functions 'catfile';
Expand Down Expand Up @@ -109,15 +109,7 @@ sub get_line {
return $line;
}
sub hmac_sha1_sum {
my ($str, $secret) = @_;
$secret = $secret ? "$secret" : 'Very insecure!';
$secret = sha1 $secret if length $secret > 64;
my $ipad = $secret ^ (chr(0x36) x 64);
my $opad = $secret ^ (chr(0x5c) x 64);
return unpack 'H*', sha1($opad . sha1($ipad . $str));
}
sub hmac_sha1_sum { unpack 'H*', hmac_sha1(@_) }
sub html_unescape {
my $str = shift;
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious.pm
Expand Up @@ -41,7 +41,7 @@ has static => sub { Mojolicious::Static->new };
has types => sub { Mojolicious::Types->new };

our $CODENAME = 'Top Hat';
our $VERSION = '4.07';
our $VERSION = '4.08';

sub AUTOLOAD {
my $self = shift;
Expand Down

0 comments on commit f7afcd5

Please sign in to comment.