Debian Codegraph @

README

raw
1 NAME
2
3 Crypt::xxHash - xxHash implementation for Perl
4
5 SYNOPSIS
6
7 use Crypt::xxHash qw/
8 xxhash32 xxhash32_hex
9 xxhash64 xxhash64_hex
10 xxhash3_64bits xxhash3_64bits_hex
11 xxhash3_128bits_hex /;
12
13 my $hash = xxhash32( $data, $seed );
14 my $hex = xxhash32_hex( $data, $seed );
15
16 my $hash_64 = xxhash64( $data, $seed );
17 my $hex_64 = xxhash64_hex( $data, $seed );
18
19 my $hash_64 = xxhash3_64bits( $data, $seed );
20 my $hex_64 = xxhash3_64bits_hex( $data, $seed );
21
22 my $hex_128 = xxhash3_128bits_hex( $data, $seed );
23
24 DESCRIPTION
25
26 xxHash is a super fast algorithm that claims to work at speeds close to
27 RAM limits. This package provides 32- and 64-bit hash functions. As
28 bonus it provides 128-bit hex method.
29
30 This package was inspired by Digest::xxHash, but it includes the fresh
31 C code and has some optimisations. Thus all hex methods are implemented
32 in Perl XS. Also this module doesn't use Math::Int64 in favor of native
33 64 bit digits.
34
35 The used version of xxHash is v0.8.0
36
37 $h = xxhash32( $data, $seed )
38
39 Returns a 32 bit hash.
40
41 $h = xxhash32_hex( $data, $seed )
42
43 Returns a 32 bit hash converted into hex string.
44
45 $h = xxhash64( $data, $seed )
46
47 Returns a 64 bit hash.
48
49 $h = xxhash64_hex( $data, $seed )
50
51 Returns a 64 bit hash converted into hex string
52
53 $h = xxhash3_64bits( $data, $seed )
54
55 Returns a 64 bit hash which calculated by using xxHash3 algorithm.
56
57 $h = xxhash3_64bits_hex( $data, $seed )
58
59 Returns a 64 bit hash which calculated by using xxHash3 algorithm. This
60 hash is converted into hex string.
61
62 $h = xxhash3_128its_hex( $data, $seed )
63
64 Returns a 128 bit hash which calculated by using xxHash3 algorithm.
65 This hash is converted into hex string.
66
67 $stream = xxhash3_64bits_stream($seed) =head2
68 xxhash3_64bits_stream_update($stream, $more_data) =head2 $h =
69 xxhash3_64bits_stream_digest($stream) =head2 $h =
70 xxhash3_64bits_stream_digest_hex($stream)
71
72 Get a 64 bit hash from segmented data by calling
73 xxhash3_64bits_stream_update multiple times.
74
75 sub hash_a_file {
76 my($fh) = @_;
77 my $stream = xxhash3_64bits_stream(12345);
78 my $buf;
79 while( read $fh, $buf, 1024 ) {
80 xxhash3_64bits_stream_update($stream, $buf);
81 }
82 return xxhash3_64bits_stream_digest($stream);
83 # return xxhash3_64bits_stream_digest_hex($stream); # hex version
84 } # the resources $stream occupied will be released here.
85
86 SPEED
87
88 There are some official benchmark results can be found on the project
89 web-site https://github.com/Cyan4973/xxHash
90
91 BENCHMARKS
92
93 Below you can find some benchmarks in comparison with Digest::xxHash.
94
95 The "xxhash32" methods in those two packages have the same realisation.
96 so they have the same throughput capacity.
97
98 But other methods have some differences:
99
100 Rate Digest::xxHash::xxhash32_hex Crypt::xxHash::xxhash32_hex
101 Digest::xxHash::xxhash32_hex 2577320/s -- -54%
102 Crypt::xxHash::xxhash32_hex 5543237/s 115% --
103
104 Rate Digest::xxHash::xxhash64 Crypt::xxHash::xxhash64
105 Digest::xxHash::xxhash64 201729/s -- -99%
106 Crypt::xxHash::xxhash64 14893617/s 7283% --
107
108 Rate Digest::xxHash::xxhash64_hex Crypt::xxHash::xxhash64_hex
109 Digest::xxHash::xxhash64_hex 185048/s -- -96%
110 Crypt::xxHash::xxhash64_hex 4926108/s 2562% --
111
112 LICENSE
113
114 xxHash is covered by the BSD license.
115
116 AUTHOR
117
118 Chernenko Dmitiry [email protected]
119
120 xxHash by Yann Collet.
121