line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# mt-aws-glacier - Amazon Glacier sync client |
2
|
|
|
|
|
|
|
# Copyright (C) 2012-2014 Victor Efimov |
3
|
|
|
|
|
|
|
# http://mt-aws.com (also http://vs-dev.com) vs@vs-dev.com |
4
|
|
|
|
|
|
|
# License: GPLv3 |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This file is part of "mt-aws-glacier" |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# mt-aws-glacier is free software: you can redistribute it and/or modify |
9
|
|
|
|
|
|
|
# it under the terms of the GNU General Public License as published by |
10
|
|
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or |
11
|
|
|
|
|
|
|
# (at your option) any later version. |
12
|
|
|
|
|
|
|
# |
13
|
|
|
|
|
|
|
# mt-aws-glacier is distributed in the hope that it will be useful, |
14
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
15
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16
|
|
|
|
|
|
|
# GNU General Public License for more details. |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
19
|
|
|
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package App::MtAws::SHAHash; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $VERSION = '1.114_2'; |
25
|
|
|
|
|
|
|
|
26
|
19
|
|
|
19
|
|
101919
|
use strict; |
|
19
|
|
|
|
|
22
|
|
|
19
|
|
|
|
|
478
|
|
27
|
19
|
|
|
19
|
|
63
|
use warnings; |
|
19
|
|
|
|
|
31
|
|
|
19
|
|
|
|
|
436
|
|
28
|
19
|
|
|
19
|
|
760
|
use Digest::SHA; |
|
19
|
|
|
|
|
4394
|
|
|
19
|
|
|
|
|
509
|
|
29
|
19
|
|
|
19
|
|
59
|
use Carp; |
|
19
|
|
|
|
|
70
|
|
|
19
|
|
|
|
|
1154
|
|
30
|
|
|
|
|
|
|
|
31
|
19
|
|
|
19
|
|
85
|
use Exporter 'import'; |
|
19
|
|
|
|
|
24
|
|
|
19
|
|
|
|
|
2997
|
|
32
|
|
|
|
|
|
|
our @EXPORT_OK = qw/large_sha256_hex/; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
sub large_sha256_hex |
36
|
|
|
|
|
|
|
{ |
37
|
140
|
50
|
|
140
|
0
|
81271
|
return Digest::SHA::sha256_hex($_[0]) if $Digest::SHA::VERSION ge '5.63'; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
0
|
|
|
|
my $chunksize = $_[1] || 4*1024*1024; |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $sha = Digest::SHA->new(256); |
42
|
0
|
|
|
|
|
|
my $size = length($_[0]); |
43
|
|
|
|
|
|
|
|
44
|
0
|
|
|
|
|
|
my $offset = 0; |
45
|
0
|
|
|
|
|
|
while ($offset < $size) { |
46
|
0
|
|
|
|
|
|
$sha->add(substr($_[0], $offset, $chunksize)); |
47
|
0
|
|
|
|
|
|
$offset += $chunksize; |
48
|
|
|
|
|
|
|
} |
49
|
0
|
|
|
|
|
|
$sha->hexdigest; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |