1Dpkg::Checksums(3perl)           libdpkg-perl           Dpkg::Checksums(3perl)
2
3
4

NAME

6       Dpkg::Checksums - generate and manipulate file checksums
7

DESCRIPTION

9       This module provides a class that can generate and manipulate various
10       file checksums as well as some methods to query information about
11       supported checksums.
12

FUNCTIONS

14       @list = checksums_get_list()
15           Returns the list of supported checksums algorithms.
16
17       $bool = checksums_is_supported($alg)
18           Returns a boolean indicating whether the given checksum algorithm
19           is supported. The checksum algorithm is case-insensitive.
20
21       $value = checksums_get_property($alg, $property)
22           Returns the requested property of the checksum algorithm. Returns
23           undef if either the property or the checksum algorithm doesn't
24           exist. Valid properties currently include "name" (returns the name
25           of the digest algorithm), "regex" for the regular expression
26           describing the common string representation of the checksum, and
27           "strong" for a boolean describing whether the checksum algorithm is
28           considered cryptographically strong.
29

METHODS

31       $ck = Dpkg::Checksums->new()
32           Create a new Dpkg::Checksums object. This object is able to store
33           the checksums of several files to later export them or verify them.
34
35       $ck->reset()
36           Forget about all checksums stored. The object is again in the same
37           state as if it was newly created.
38
39       $ck->add_from_file($filename, %opts)
40           Add or verify checksums information for the file $filename. The
41           file must exists for the call to succeed. If you don't want the
42           given filename to appear when you later export the checksums you
43           might want to set the "key" option with the public name that you
44           want to use. Also if you don't want to generate all the checksums,
45           you can pass an array reference of the wanted checksums in the
46           "checksums" option.
47
48           It the object already contains checksums information associated the
49           filename (or key), it will error out if the newly computed
50           information does not match what's stored, and the caller did not
51           request that it be updated with the boolean "update" option.
52
53       $ck->add_from_string($alg, $value, %opts)
54           Add checksums of type $alg that are stored in the $value variable.
55           $value can be multi-lines, each line should be a space separated
56           list of checksum, file size and filename. Leading or trailing
57           spaces are not allowed.
58
59           It the object already contains checksums information associated to
60           the filenames, it will error out if the newly read information does
61           not match what's stored, and the caller did not request that it be
62           updated with the boolean "update" option.
63
64       $ck->add_from_control($control, %opts)
65           Read checksums from Checksums-* fields stored in the Dpkg::Control
66           object $control. It uses $self->add_from_string() on the field
67           values to do the actual work.
68
69           If the option "use_files_for_md5" evaluates to true, then the
70           "Files" field is used in place of the "Checksums-Md5" field. By
71           default the option is false.
72
73       @files = $ck->get_files()
74           Return the list of files whose checksums are stored in the object.
75
76       $bool = $ck->has_file($file)
77           Return true if we have checksums for the given file. Returns false
78           otherwise.
79
80       $ck->remove_file($file)
81           Remove all checksums of the given file.
82
83       $checksum = $ck->get_checksum($file, $alg)
84           Return the checksum of type $alg for the requested $file. This will
85           not compute the checksum but only return the checksum stored in the
86           object, if any.
87
88           If $alg is not defined, it returns a reference to a hash: keys are
89           the checksum algorithms and values are the checksums themselves.
90           The hash returned must not be modified, it's internal to the
91           object.
92
93       $size = $ck->get_size($file)
94           Return the size of the requested file if it's available in the
95           object.
96
97       $bool = $ck->has_strong_checksums($file)
98           Return a boolean on whether the file has a strong checksum.
99
100       $ck->export_to_string($alg, %opts)
101           Return a multi-line string containing the checksums of type $alg.
102           The string can be stored as-is in a Checksum-* field of a
103           Dpkg::Control object.
104
105       $ck->export_to_control($control, %opts)
106           Export the checksums in the Checksums-* fields of the Dpkg::Control
107           $control object.
108

CHANGES

110   Version 1.04 (dpkg 1.20.0)
111       Remove warning: For obsolete property 'program'.
112
113   Version 1.03 (dpkg 1.18.5)
114       New property: Add new 'strong' property.
115
116       New member: $ck->has_strong_checksums().
117
118   Version 1.02 (dpkg 1.18.0)
119       Obsolete property: Getting the 'program' checksum property will warn
120       and return undef, the Digest module is used internally now.
121
122       New property: Add new 'name' property with the name of the Digest
123       algorithm to use.
124
125   Version 1.01 (dpkg 1.17.6)
126       New argument: Accept an options argument in $ck->export_to_string().
127
128       New option: Accept new option 'update' in $ck->add_from_file() and
129       $ck->add_from_control().
130
131   Version 1.00 (dpkg 1.15.6)
132       Mark the module as public.
133
134
135
1361.21.21                           2023-07-19            Dpkg::Checksums(3perl)
Impressum