|
Line 0
Link Here
|
| 0 |
- |
1 |
package Koha::Util::Misc; |
|
|
2 |
|
| 3 |
# Copyright 2024 Koha Development Team |
| 4 |
# |
| 5 |
# This file is part of Koha. |
| 6 |
# |
| 7 |
# Koha is free software; you can redistribute it and/or modify it |
| 8 |
# under the terms of the GNU General Public License as published by |
| 9 |
# the Free Software Foundation; either version 3 of the License, or |
| 10 |
# (at your option) any later version. |
| 11 |
# |
| 12 |
# Koha is distributed in the hope that it will be useful, but |
| 13 |
# WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
# GNU General Public License for more details. |
| 16 |
# |
| 17 |
# You should have received a copy of the GNU General Public License |
| 18 |
# along with Koha; if not, see <http://www.gnu.org/licenses>. |
| 19 |
|
| 20 |
use Modern::Perl; |
| 21 |
use Digest::MD5 qw( md5_hex ); |
| 22 |
use Sereal::Encoder qw( encode_sereal ); |
| 23 |
|
| 24 |
use Exporter 'import'; |
| 25 |
|
| 26 |
BEGIN { |
| 27 |
our @EXPORT_OK = qw( digest ); |
| 28 |
} |
| 29 |
|
| 30 |
=head1 NAME |
| 31 |
|
| 32 |
Koha::Util::Misc - utility class with miscellaneous routines |
| 33 |
|
| 34 |
=head1 METHODS |
| 35 |
|
| 36 |
=head2 digest |
| 37 |
|
| 38 |
Calculates a md5_hex digest of the given argument (any Perl data structure). |
| 39 |
|
| 40 |
=cut |
| 41 |
|
| 42 |
sub digest { |
| 43 |
my $data = shift; |
| 44 |
return md5_hex( encode_sereal( ( ref $data eq '' ) ? \$data : $data, { sort_keys => 1 } ) ); |
| 45 |
} |
| 46 |
|
| 47 |
1; |
| 48 |
__END__ |
| 49 |
|
| 50 |
=head1 AUTHOR |
| 51 |
|
| 52 |
Koha Development Team <http://koha-community.org/> |
| 53 |
|
| 54 |
Janusz Kaczmarek <januszop@gmail.com> |
| 55 |
|
| 56 |
=cut |