1 package Digest
::HighwayHash
;
6 use parent qw
/Exporter/;
8 our @EXPORT_OK = qw
/highway_hash64 highway_hash128 highway_hash256/;
9 our @EXPORT = @EXPORT_OK;
11 our $VERSION = '0.001001';
16 XSLoader
::load
('Digest::HighwayHash', $VERSION);
25 Digest::HighwayHash - XS fast strong keyed hash function
29 use Digest::HighwayHash;
30 say highway_hash64 [1, 2, 3, 4], 'hello';
31 # 11956820856122239241
32 say join ' ', @{highway_hash128([1, 2, 3, 4], 'hello')};
33 # 3048112761216189476 13900443277579286659
34 say join ' ', @{highway_hash256([1, 2, 3, 4], 'hello')};
35 # 8099666330974151427 17027479935588128037 4015249936799013189 10027181291351549853
37 my $state = Digest::HighwayHash->new([1, 2, 3, 4]);
39 $state->append('llo');
40 say join ' ', @{$state->finish128};
41 # 3048112761216189476 13900443277579286659
45 HighwayHash is a fast and strong keyed hash function, documented at
46 L<https://github.com/google/highwayhash>.
48 This module has a procedural interface (used to hash an entire
49 message) and an OO interface (used to hash a message bit by bit). The
50 procedural interface is made of three functions, all exported by
55 =item B<highway_hash64> I<\@key>, I<$input>
57 Compute the 64-bit HighwayHash of I<$input>, using I<\@key> as a key.
58 The key must be a 4-element arrayref, with each element either a
59 number or (on Perls without 64-bit numbers) a L<Math::Int64> object. The result is a single number or (on Perls without 64-bit numbers) a L<Math::Int64> object.
61 =item B<highway_hash128> I<\@key>, I<$input>
63 Compute the 128-bit HighwayHash of I<$input>, using I<\@key> as a key.
64 The key must be a 4-element arrayref, with each element either a
65 number or (on Perls without 64-bit numbers) a L<Math::Int64> object. The result is an array of exactly two numbers or (on Perls without 64-bit numbers) L<Math::Int64> objects.
67 =item B<highway_hash256> I<\@key>, I<$input>
69 Compute the 256-bit HighwayHash of I<$input>, using I<\@key> as a key.
70 The key must be a 4-element arrayref, with each element either a
71 number or (on Perls without 64-bit numbers) a L<Math::Int64> object. The result is an array of exactly four numbers or (on Perls without 64-bit numbers) L<Math::Int64> objects.
76 The OO interface has these methods:
80 =item Digest::HighwayHash->B<new>(I<\@key>)
82 Initialize a new C<Digest::HighwayHash> state with a given key. The
83 B<append> method will be called with this state and parts of the
84 message, and then one of the B<finish*> methods will be called to
87 =item $state->B<append>(I<$input>)
89 Append I<$input> to the message to be hashed by $state.
91 =item $state->B<finish64>
93 =item $state->B<finish128>
95 =item $state->B<finish256>
97 Compute and return the 64-bit, 128-bit, or respectively 256-bit
98 HighwayHash of this state. The return values are the same as in the
105 L<https://github.com/google/highwayhash>
109 Marius Gavrilescu, E<lt>marius@ieval.roE<gt>
111 =head1 COPYRIGHT AND LICENSE
113 Copyright (C) 2018 by Marius Gavrilescu
115 This library is free software; you can redistribute it and/or modify
116 it under the same terms as Perl itself, either Perl version 5.24.1 or,
117 at your option, any later version of Perl 5 you may have available.
This page took 0.02658 seconds and 4 git commands to generate.