line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vim: set expandtab ts=4 sw=4 nowrap ft=perl ff=unix : |
2
|
|
|
|
|
|
|
package Digest::BLAKE2s; |
3
|
2
|
|
|
2
|
|
12
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
44
|
|
4
|
2
|
|
|
2
|
|
8
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
65
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.02'; # FIXME |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
8
|
use parent qw/Exporter Digest::base/; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
8
|
|
9
|
2
|
|
|
2
|
|
94
|
use XSLoader; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
112
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
XSLoader::load __PACKAGE__, $VERSION; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @EXPORT_OK = qw( |
14
|
|
|
|
|
|
|
blake2s blake2s_hex blake2s_base64 blake2s_base64url blake2s_ascii85 |
15
|
|
|
|
|
|
|
); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
1; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 NAME |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Digest::BLAKE2s - Perl XS interface to the BLAKE2s algorithm |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Digest::BLAKE2s qw(blake2s blake2s_hex blake2s_base64 blake2s_base64url blake2s_ascii85); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# blake2b |
28
|
|
|
|
|
|
|
print blake2s('Japan Break Industries'); |
29
|
|
|
|
|
|
|
print blake2s_hex('Japan Break Industries'); |
30
|
|
|
|
|
|
|
print blake2s_base64('Japan Break Industries'); |
31
|
|
|
|
|
|
|
print blake2s_base64url('Japan Break Industries'); |
32
|
|
|
|
|
|
|
print blake2s_ascii85('Japan Break Industries'); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# object interface provided by Digest::base |
35
|
|
|
|
|
|
|
my $b = Digest::BLAKE2s->new; |
36
|
|
|
|
|
|
|
$b->add('Japan Break Industries'); |
37
|
|
|
|
|
|
|
print $b->digest; |
38
|
|
|
|
|
|
|
print $b->b64digest; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
The C module provides an interface to the BLAKE2s message |
43
|
|
|
|
|
|
|
digest algorithm. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
The cryptographic hash function BLAKE2 is an improved version of the SHA-3 finalist BLAKE. |
46
|
|
|
|
|
|
|
Like BLAKE or SHA-3, BLAKE2 offers the highest security, yet is fast as MD5 on 64-bit platforms and requires at least 33% less RAM than SHA-2 or SHA-3 on low-end systems. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
BLAKE2 comes in two flavors. |
49
|
|
|
|
|
|
|
BLAKE2b is optimized for 64-bit platforms—including NEON-enabled ARMs—and produces digests of any size between 1 and 64 bytes. |
50
|
|
|
|
|
|
|
BLAKE2s is optimized for 8- to 32-bit platforms and produces digests of any size between 1 and 32 bytes. |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
This interface follows the conventions set forth by the C module. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 FUNCTIONS |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
None of these functions are exported by default. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 blake2s($data, ...) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Logically joins the arguments into a single string, and returns its BLAKE2s |
61
|
|
|
|
|
|
|
digest encoded as a binary string. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 blake2s_hex($data, ...) |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Logically joins the arguments into a single string, and returns its BLAKE2s |
66
|
|
|
|
|
|
|
digest encoded as a hexadecimal string. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 blake2s_base64($data, ...) |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Logically joins the arguments into a single string, and returns its BLAKE2s |
71
|
|
|
|
|
|
|
digest encoded as a Base64 string, without any trailing padding. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 blake2s_base64url($data, ...) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Logically joins the arguments into a single string, and returns its BLAKE2s |
76
|
|
|
|
|
|
|
digest encoded as a urlsafe Base64 string, without any trailing padding. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 blake2s_ascii85($data, ...) |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Logically joins the arguments into a single string, and returns its BLAKE2s |
81
|
|
|
|
|
|
|
digest encoded as a Ascii85 string, without any trailing padding. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SEE ALSO |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
C |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 AUTHOR |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Tasuku SUENAGA a.k.a. gunyarakun Etasuku-s-cpan ATAT titech.acE |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 LICENSE |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Copyright (C) Tasuku SUENAGA a.k.a. gunyarakun |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify |
96
|
|
|
|
|
|
|
it under the same terms as Perl itself. |
97
|
|
|
|
|
|
|
=cut |