1Crypt::Misc(3)        User Contributed Perl Documentation       Crypt::Misc(3)
2
3
4

NAME

6       Crypt::Misc - miscellaneous functions related to (or used by) CryptX
7

SYNOPSIS

9       This module contains a collection of mostly unsorted functions loosely-
10       related to CryptX distribution but not implementing cryptography.
11
12       Most of them are also available in other perl modules but once you
13       utilize CryptX you might avoid dependencies on other modules by using
14       functions from Crypt::Misc.
15

DESCRIPTION

17        use Crypt::Misc ':all';
18
19        # Base64 and Base64/URL-safe functions
20        $base64    = encode_b64($rawbytes);
21        $rawbytes  = decode_b64($base64);
22        $base64url = encode_b64u($encode_b64u);
23        $rawbytes  = decode_b64u($base64url);
24
25        # read/write file
26        $rawdata = read_rawfile($filename);
27        write_rawfile($filename, $rawdata);
28
29        # convert PEM/DER
30        $der_data = pem_to_der($pem_data);
31        $pem_data = der_to_pem($der_data);
32
33         # others
34         die "mismatch" unless slow_eq($str1, $str2);
35

FUNCTIONS

37       By default, Crypt::Misc doesn't import any function. You can import
38       individual functions like this:
39
40        use Crypt::Misc qw(read_rawfile);
41
42       Or import all available functions:
43
44        use Crypt::Misc ':all';
45
46   encode_b64
47       Since: 0.029
48
49        $base64string = encode_b64($rawdata);
50
51       Encode $rawbytes into Base64 string, no line-endings in the output
52       string.
53
54   decode_b64
55       Since: 0.029
56
57        $rawdata = decode_b64($base64string);
58
59       Decode a Base64 string.
60
61   encode_b64u
62       Since: 0.029
63
64        $base64url_string = encode_b64($rawdata);
65
66       Encode $rawbytes into Base64/URL-Safe string, no line-endings in the
67       output string.
68
69   decode_b64u
70       Since: 0.029
71
72        $rawdata = decode_b64($base64url_string);
73
74       Decode a Base64/URL-Safe string.
75
76   encode_b32r
77       Since: 0.049
78
79        $string = encode_b32r($rawdata);
80
81       Encode bytes into Base32 (rfc4648 alphabet) string, without "="
82       padding.
83
84   decode_b32r
85       Since: 0.049
86
87        $rawdata = decode_b32r($string);
88
89       Decode a Base32 (rfc4648 alphabet) string into bytes.
90
91   encode_b32b
92       Since: 0.049
93
94        $string = encode_b32b($rawdata);
95
96       Encode bytes into Base32 (base32hex alphabet) string, without "="
97       padding.
98
99   decode_b32b
100       Since: 0.049
101
102        $rawdata = decode_b32b($string);
103
104       Decode a Base32 (base32hex alphabet) string into bytes.
105
106   encode_b32z
107       Since: 0.049
108
109        $string = encode_b32z($rawdata);
110
111       Encode bytes into Base32 (zbase32 alphabet) string.
112
113   decode_b32z
114       Since: 0.049
115
116        $rawdata = decode_b32z($string);
117
118       Decode a Base32 (zbase32 alphabet) string into bytes.
119
120   encode_b32c
121       Since: 0.049
122
123        $string = encode_b32c($rawdata);
124
125       Encode bytes into Base32 (crockford alphabet) string.
126
127   decode_b32c
128       Since: 0.049
129
130        $rawdata = decode_b32c($string);
131
132       Decode a Base32 (crockford alphabet) string into bytes.
133
134   encode_b58b
135       Since: 0.049
136
137        $string = encode_b58b($rawdata);
138
139       Encode bytes into Base58 (Bitcoin alphabet) string.
140
141   decode_b58b
142       Since: 0.049
143
144        $rawdata = decode_b58b($string);
145
146       Decode a Base58 (Bitcoin alphabet) string into bytes.
147
148   encode_b58f
149       Since: 0.049
150
151        $string = encode_b58f($rawdata);
152
153       Encode bytes into Base58 (Flickr alphabet) string.
154
155   decode_b58f
156       Since: 0.049
157
158        $rawdata = decode_b58f($string);
159
160       Decode a Base58 (Flickr alphabet) string into bytes.
161
162   encode_b58r
163       Since: 0.049
164
165        $string = encode_b58r($rawdata);
166
167       Encode bytes into Base58 (Ripple alphabet) string.
168
169   decode_b58r
170       Since: 0.049
171
172        $rawdata = decode_b58r($string);
173
174       Decode a Base58 (Ripple alphabet) string into bytes.
175
176   encode_b58t
177       Since: 0.049
178
179        $string = encode_b58t($rawdata);
180
181       Encode bytes into Base58 (Tipple alphabet) string.
182
183   decode_b58t
184       Since: 0.049
185
186        $rawdata = decode_b58t($string);
187
188       Decode a Base58 (Tipple alphabet) string into bytes.
189
190   encode_b58s
191       Since: 0.049
192
193        $string = encode_b58s($rawdata);
194
195       Encode bytes into Base58 (Stellar alphabet) string.
196
197   decode_b58s
198       Since: 0.049
199
200        $rawdata = decode_b58s($string);
201
202       Decode a Base58 (Stellar alphabet) string into bytes.
203
204   read_rawfile
205       Since: 0.029
206
207        $rawdata = read_rawfile($filename);
208
209       Read file $filename into a scalar as a binary data (without
210       decoding/transformation).
211
212   write_rawfile
213       Since: 0.029
214
215        write_rawfile($filename, $rawdata);
216
217       Write $rawdata to file <$filename> as binary data.
218
219   slow_eq
220       Since: 0.029
221
222        if (slow_eq($data1, $data2)) { ... }
223
224       Constant time compare (to avoid timing side-channel).
225
226   pem_to_der
227       Since: 0.029
228
229         $der_data = pem_to_der($pem_data);
230         #or
231         $der_data = pem_to_der($pem_data, $password);
232
233       Convert PEM to DER representation. Supports also password protected PEM
234       data.
235
236   der_to_pem
237       Since: 0.029
238
239         $pem_data = der_to_pem($pem_data, $header_name);
240         #or
241         $pem_data = der_to_pem($pem_data, $header_name, $password);
242         #or
243         $pem_data = der_to_pem($pem_data, $header_name, $passord, $cipher_name);
244
245         # $header_name e.g. "PUBLIC KEY", "RSA PRIVATE KEY" ...
246         # $cipher_name e.g. "DES-EDE3-CBC", "AES-256-CBC" (DEFAULT) ...
247
248       Convert DER to PEM representation. Supports also password protected PEM
249       data.
250
251   random_v4uuid
252       Since: 0.031
253
254        my $uuid = random_v4uuid();
255
256       Returns cryptographically strong Version 4 random UUID:
257       "xxxxxxxx-xxxx-4xxx-Yxxx-xxxxxxxxxxxx" where "x" is any hexadecimal
258       digit and "Y" is one of 8, 9, A, B (1000, 1001, 1010, 1011) e.g.
259       "f47ac10b-58cc-4372-a567-0e02b2c3d479".
260
261   is_v4uuid
262       Since: 0.031
263
264         if (is_v4uuid($uuid)) {
265           ...
266         }
267
268       Checks the given $uuid string whether it matches V4 UUID format and
269       returns 0 (mismatch) or 1 (match).
270
271   increment_octets_le
272       Since: 0.048
273
274        $octects = increment_octets_le($octets);
275
276       Take input $octets as a little-endian big number and return an
277       increment.
278
279   increment_octets_be
280       Since: 0.048
281
282        $octects = increment_octets_be($octets);
283
284       Take input $octets as a big-endian big number and return an increment.
285

SEE ALSO

287       ยท   CryptX
288
289
290
291perl v5.28.1                      2019-02-02                    Crypt::Misc(3)
Impressum