From b3ec381ed12b039cede8386b80ad2cb11c0af03d Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 23 Jun 2018 20:50:56 +0300 Subject: [PATCH] Also write documentation --- lib/Digest/HighwayHash.pm | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/lib/Digest/HighwayHash.pm b/lib/Digest/HighwayHash.pm index e69ad0a..201886d 100644 --- a/lib/Digest/HighwayHash.pm +++ b/lib/Digest/HighwayHash.pm @@ -34,12 +34,21 @@ Digest::HighwayHash - XS fast strong keyed hash function say join ' ', @{highway_hash256([1, 2, 3, 4], 'hello')}; # 8099666330974151427 17027479935588128037 4015249936799013189 10027181291351549853 + my $state = Digest::HighwayHash->new([1, 2, 3, 4]); + $state->append('he'); + $state->append('llo'); + say join ' ', @{$state->finish128}; + # 3048112761216189476 13900443277579286659 + =head1 DESCRIPTION HighwayHash is a fast and strong keyed hash function, documented at L. -Three functions are exported by this module, all by default: +This module has a procedural interface (used to hash an entire +message) and an OO interface (used to hash a message bit by bit). The +procedural interface is made of three functions, all exported by +default: =over @@ -62,6 +71,33 @@ The key must be a 4-element arrayref, with each element either a number or (on Perls without 64-bit numbers) a L object. The result is an array of exactly four numbers or (on Perls without 64-bit numbers) L objects. +=back + +The OO interface has these methods: + +=over + +=item Digest::HighwayHash->B(I<\@key>) + +Initialize a new C state with a given key. The +B method will be called with this state and parts of the +message, and then one of the B methods will be called to +compute the result. + +=item $state->B(I<$input>) + +Append I<$input> to the message to be hashed by $state. + +=item $state->B + +=item $state->B + +=item $state->B + +Compute and return the 64-bit, 128-bit, or respectively 256-bit +HighwayHash of this state. The return values are the same as in the +procedural interface. + =back =head1 SEE ALSO -- 2.30.2