1Crypt::Digest::SHA512_2U5s6e(r3)Contributed Perl DocumenCtraytpito:n:Digest::SHA512_256(3)
2
3
4

NAME

6       Crypt::Digest::SHA512_256 - Hash function SHA-512/256 [size: 256 bits]
7

SYNOPSIS

9          ### Functional interface:
10          use Crypt::Digest::SHA512_256 qw( sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u
11                                       sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u );
12
13          # calculate digest from string/buffer
14          $sha512_256_raw  = sha512_256('data string');
15          $sha512_256_hex  = sha512_256_hex('data string');
16          $sha512_256_b64  = sha512_256_b64('data string');
17          $sha512_256_b64u = sha512_256_b64u('data string');
18          # calculate digest from file
19          $sha512_256_raw  = sha512_256_file('filename.dat');
20          $sha512_256_hex  = sha512_256_file_hex('filename.dat');
21          $sha512_256_b64  = sha512_256_file_b64('filename.dat');
22          $sha512_256_b64u = sha512_256_file_b64u('filename.dat');
23          # calculate digest from filehandle
24          $sha512_256_raw  = sha512_256_file(*FILEHANDLE);
25          $sha512_256_hex  = sha512_256_file_hex(*FILEHANDLE);
26          $sha512_256_b64  = sha512_256_file_b64(*FILEHANDLE);
27          $sha512_256_b64u = sha512_256_file_b64u(*FILEHANDLE);
28
29          ### OO interface:
30          use Crypt::Digest::SHA512_256;
31
32          $d = Crypt::Digest::SHA512_256->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

DESCRIPTION

42       Provides an interface to the SHA512_256 digest algorithm.
43

EXPORT

45       Nothing is exported by default.
46
47       You can export selected functions:
48
49         use Crypt::Digest::SHA512_256 qw(sha512_256 sha512_256_hex sha512_256_b64 sha512_256_b64u
50                                             sha512_256_file sha512_256_file_hex sha512_256_file_b64 sha512_256_file_b64u);
51
52       Or all of them at once:
53
54         use Crypt::Digest::SHA512_256 ':all';
55

FUNCTIONS

57   sha512_256
58       Logically joins all arguments into a single string, and returns its
59       SHA512_256 digest encoded as a binary string.
60
61        $sha512_256_raw = sha512_256('data string');
62        #or
63        $sha512_256_raw = sha512_256('any data', 'more data', 'even more data');
64
65   sha512_256_hex
66       Logically joins all arguments into a single string, and returns its
67       SHA512_256 digest encoded as a hexadecimal string.
68
69        $sha512_256_hex = sha512_256_hex('data string');
70        #or
71        $sha512_256_hex = sha512_256_hex('any data', 'more data', 'even more data');
72
73   sha512_256_b64
74       Logically joins all arguments into a single string, and returns its
75       SHA512_256 digest encoded as a Base64 string, with trailing '='
76       padding.
77
78        $sha512_256_b64 = sha512_256_b64('data string');
79        #or
80        $sha512_256_b64 = sha512_256_b64('any data', 'more data', 'even more data');
81
82   sha512_256_b64u
83       Logically joins all arguments into a single string, and returns its
84       SHA512_256 digest encoded as a Base64 URL Safe string (see RFC 4648
85       section 5).
86
87        $sha512_256_b64url = sha512_256_b64u('data string');
88        #or
89        $sha512_256_b64url = sha512_256_b64u('any data', 'more data', 'even more data');
90
91   sha512_256_file
92       Reads file (defined by filename or filehandle) content, and returns its
93       SHA512_256 digest encoded as a binary string.
94
95        $sha512_256_raw = sha512_256_file('filename.dat');
96        #or
97        $sha512_256_raw = sha512_256_file(*FILEHANDLE);
98
99   sha512_256_file_hex
100       Reads file (defined by filename or filehandle) content, and returns its
101       SHA512_256 digest encoded as a hexadecimal string.
102
103        $sha512_256_hex = sha512_256_file_hex('filename.dat');
104        #or
105        $sha512_256_hex = sha512_256_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   sha512_256_file_b64
111       Reads file (defined by filename or filehandle) content, and returns its
112       SHA512_256 digest encoded as a Base64 string, with trailing '='
113       padding.
114
115        $sha512_256_b64 = sha512_256_file_b64('filename.dat');
116        #or
117        $sha512_256_b64 = sha512_256_file_b64(*FILEHANDLE);
118
119   sha512_256_file_b64u
120       Reads file (defined by filename or filehandle) content, and returns its
121       SHA512_256 digest encoded as a Base64 URL Safe string (see RFC 4648
122       section 5).
123
124        $sha512_256_b64url = sha512_256_file_b64u('filename.dat');
125        #or
126        $sha512_256_b64url = sha512_256_file_b64u(*FILEHANDLE);
127

METHODS

129       The OO interface provides the same set of functions as Crypt::Digest.
130
131   new
132        $d = Crypt::Digest::SHA512_256->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::SHA512_256->hashsize();
159        #or
160        Crypt::Digest::SHA512_256::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

SEE ALSO

175       •   CryptX, Crypt::Digest
176
177       •   <https://en.wikipedia.org/wiki/SHA-2>
178
179
180
181perl v5.38.0                      2023-10-04      Crypt::Digest::SHA512_256(3)
Impressum