1Crypt::Digest::BLAKE2s_U1s6e0r(3C)ontributed Perl DocumeCnrtyaptti:o:nDigest::BLAKE2s_160(3)
2
3
4
6 Crypt::Digest::BLAKE2s_160 - Hash function BLAKE2s [size: 160 bits]
7
9 ### Functional interface:
10 use Crypt::Digest::BLAKE2s_160 qw( blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
11 blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u );
12
13 # calculate digest from string/buffer
14 $blake2s_160_raw = blake2s_160('data string');
15 $blake2s_160_hex = blake2s_160_hex('data string');
16 $blake2s_160_b64 = blake2s_160_b64('data string');
17 $blake2s_160_b64u = blake2s_160_b64u('data string');
18 # calculate digest from file
19 $blake2s_160_raw = blake2s_160_file('filename.dat');
20 $blake2s_160_hex = blake2s_160_file_hex('filename.dat');
21 $blake2s_160_b64 = blake2s_160_file_b64('filename.dat');
22 $blake2s_160_b64u = blake2s_160_file_b64u('filename.dat');
23 # calculate digest from filehandle
24 $blake2s_160_raw = blake2s_160_file(*FILEHANDLE);
25 $blake2s_160_hex = blake2s_160_file_hex(*FILEHANDLE);
26 $blake2s_160_b64 = blake2s_160_file_b64(*FILEHANDLE);
27 $blake2s_160_b64u = blake2s_160_file_b64u(*FILEHANDLE);
28
29 ### OO interface:
30 use Crypt::Digest::BLAKE2s_160;
31
32 $d = Crypt::Digest::BLAKE2s_160->new;
33 $d->add('any data');
34 $d->addfile('filename.dat');
35 $d->addfile(*FILEHANDLE);
36 $result_raw = $d->digest; # raw bytes
37 $result_hex = $d->hexdigest; # hexadecimal form
38 $result_b64 = $d->b64digest; # Base64 form
39 $result_b64u = $d->b64udigest; # Base64 URL Safe form
40
42 Provides an interface to the BLAKE2s_160 digest algorithm.
43
45 Nothing is exported by default.
46
47 You can export selected functions:
48
49 use Crypt::Digest::BLAKE2s_160 qw(blake2s_160 blake2s_160_hex blake2s_160_b64 blake2s_160_b64u
50 blake2s_160_file blake2s_160_file_hex blake2s_160_file_b64 blake2s_160_file_b64u);
51
52 Or all of them at once:
53
54 use Crypt::Digest::BLAKE2s_160 ':all';
55
57 blake2s_160
58 Logically joins all arguments into a single string, and returns its
59 BLAKE2s_160 digest encoded as a binary string.
60
61 $blake2s_160_raw = blake2s_160('data string');
62 #or
63 $blake2s_160_raw = blake2s_160('any data', 'more data', 'even more data');
64
65 blake2s_160_hex
66 Logically joins all arguments into a single string, and returns its
67 BLAKE2s_160 digest encoded as a hexadecimal string.
68
69 $blake2s_160_hex = blake2s_160_hex('data string');
70 #or
71 $blake2s_160_hex = blake2s_160_hex('any data', 'more data', 'even more data');
72
73 blake2s_160_b64
74 Logically joins all arguments into a single string, and returns its
75 BLAKE2s_160 digest encoded as a Base64 string, with trailing '='
76 padding.
77
78 $blake2s_160_b64 = blake2s_160_b64('data string');
79 #or
80 $blake2s_160_b64 = blake2s_160_b64('any data', 'more data', 'even more data');
81
82 blake2s_160_b64u
83 Logically joins all arguments into a single string, and returns its
84 BLAKE2s_160 digest encoded as a Base64 URL Safe string (see RFC 4648
85 section 5).
86
87 $blake2s_160_b64url = blake2s_160_b64u('data string');
88 #or
89 $blake2s_160_b64url = blake2s_160_b64u('any data', 'more data', 'even more data');
90
91 blake2s_160_file
92 Reads file (defined by filename or filehandle) content, and returns its
93 BLAKE2s_160 digest encoded as a binary string.
94
95 $blake2s_160_raw = blake2s_160_file('filename.dat');
96 #or
97 $blake2s_160_raw = blake2s_160_file(*FILEHANDLE);
98
99 blake2s_160_file_hex
100 Reads file (defined by filename or filehandle) content, and returns its
101 BLAKE2s_160 digest encoded as a hexadecimal string.
102
103 $blake2s_160_hex = blake2s_160_file_hex('filename.dat');
104 #or
105 $blake2s_160_hex = blake2s_160_file_hex(*FILEHANDLE);
106
107 BEWARE: You have to make sure that the filehandle is in binary mode
108 before you pass it as argument to the addfile() method.
109
110 blake2s_160_file_b64
111 Reads file (defined by filename or filehandle) content, and returns its
112 BLAKE2s_160 digest encoded as a Base64 string, with trailing '='
113 padding.
114
115 $blake2s_160_b64 = blake2s_160_file_b64('filename.dat');
116 #or
117 $blake2s_160_b64 = blake2s_160_file_b64(*FILEHANDLE);
118
119 blake2s_160_file_b64u
120 Reads file (defined by filename or filehandle) content, and returns its
121 BLAKE2s_160 digest encoded as a Base64 URL Safe string (see RFC 4648
122 section 5).
123
124 $blake2s_160_b64url = blake2s_160_file_b64u('filename.dat');
125 #or
126 $blake2s_160_b64url = blake2s_160_file_b64u(*FILEHANDLE);
127
129 The OO interface provides the same set of functions as Crypt::Digest.
130
131 new
132 $d = Crypt::Digest::BLAKE2s_160->new();
133
134 clone
135 $d->clone();
136
137 reset
138 $d->reset();
139
140 add
141 $d->add('any data');
142 #or
143 $d->add('any data', 'more data', 'even more data');
144
145 addfile
146 $d->addfile('filename.dat');
147 #or
148 $d->addfile(*FILEHANDLE);
149
150 add_bits
151 $d->add_bits($bit_string); # e.g. $d->add_bits("111100001010");
152 #or
153 $d->add_bits($data, $nbits); # e.g. $d->add_bits("\xF0\xA0", 16);
154
155 hashsize
156 $d->hashsize;
157 #or
158 Crypt::Digest::BLAKE2s_160->hashsize();
159 #or
160 Crypt::Digest::BLAKE2s_160::hashsize();
161
162 digest
163 $result_raw = $d->digest();
164
165 hexdigest
166 $result_hex = $d->hexdigest();
167
168 b64digest
169 $result_b64 = $d->b64digest();
170
171 b64udigest
172 $result_b64url = $d->b64udigest();
173
175 • CryptX, Crypt::Digest
176
177 • <https://blake2.net/>
178
179 • <https://tools.ietf.org/html/rfc7693>
180
181
182
183perl v5.38.0 2023-10-04 Crypt::Digest::BLAKE2s_160(3)