line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# $Id$ |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# string::hash Brik |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
package Metabrik::String::Hash; |
7
|
1
|
|
|
1
|
|
638
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
28
|
|
8
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
44
|
|
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
8
|
use base qw(Metabrik); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
418
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
13
|
|
|
|
|
|
|
return { |
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
15
|
|
|
|
|
|
|
tags => [ qw(unstable sha sha1 sha256 sha512 md5 md5sum sum) ], |
16
|
|
|
|
|
|
|
author => 'GomoR ', |
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
18
|
|
|
|
|
|
|
commands => { |
19
|
|
|
|
|
|
|
sha1 => [ qw(data) ], |
20
|
|
|
|
|
|
|
sha256 => [ qw(data) ], |
21
|
|
|
|
|
|
|
sha512 => [ qw(data) ], |
22
|
|
|
|
|
|
|
md5 => [ qw(data) ], |
23
|
|
|
|
|
|
|
}, |
24
|
|
|
|
|
|
|
require_modules => { |
25
|
|
|
|
|
|
|
'Crypt::Digest' => [ ], |
26
|
|
|
|
|
|
|
}, |
27
|
|
|
|
|
|
|
}; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub _hash { |
31
|
0
|
|
|
0
|
|
|
my $self = shift; |
32
|
0
|
|
|
|
|
|
my ($function, $data) = @_; |
33
|
|
|
|
|
|
|
|
34
|
0
|
0
|
|
|
|
|
$self->brik_help_run_undef_arg($function, $data) or return; |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
eval("use Crypt::Digest qw(digest_data_hex);"); |
37
|
0
|
0
|
|
|
|
|
if ($@) { |
38
|
0
|
|
|
|
|
|
chomp($@); |
39
|
0
|
|
|
|
|
|
return $self->log->error("$function: unable to load function: $@"); |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return Crypt::Digest::digest_data_hex(uc($function), $data); |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub sha1 { |
46
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
47
|
0
|
|
|
|
|
|
my ($data) = @_; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $self->_hash('sha1', $data); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub sha256 { |
53
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
54
|
0
|
|
|
|
|
|
my ($data) = @_; |
55
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return $self->_hash('sha256', $data); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub sha512 { |
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my ($data) = @_; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
return $self->_hash('sha512', $data); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub md5 { |
67
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
68
|
0
|
|
|
|
|
|
my ($data) = @_; |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
return $self->_hash('md5', $data); |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
1; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
__END__ |