|
8 years ago | |
---|---|---|
.. | ||
autom4te.cache | 8 years ago | |
build-aux | 8 years ago | |
lib | 8 years ago | |
libfnv | 8 years ago | |
libfnvutil | 8 years ago | |
m4 | 8 years ago | |
man | 8 years ago | |
portable | 8 years ago | |
tools | 8 years ago | |
AUTHORS | 8 years ago | |
COPYING | 8 years ago | |
ChangeLog | 8 years ago | |
INSTALL | 8 years ago | |
LICENSE | 8 years ago | |
Makefile | 8 years ago | |
Makefile.am | 8 years ago | |
Makefile.in | 8 years ago | |
NEWS | 8 years ago | |
README | 8 years ago | |
README.md | 8 years ago | |
aclocal.m4 | 8 years ago | |
autogen | 8 years ago | |
circle.yml | 8 years ago | |
config.h | 8 years ago | |
config.h.in | 8 years ago | |
config.h.in~ | 8 years ago | |
config.log | 8 years ago | |
config.status | 8 years ago | |
configure | 8 years ago | |
configure.ac | 8 years ago | |
libtool | 8 years ago | |
stamp-h1 | 8 years ago |
README.md
libfnv
C language FNV hash function library with all supported bit lengths of FNV-1a: 32, 64, 128, 256, 512, and 1024
Compilation instructions
Clone from repo:
git clone https://github.com/fnvhash/libfnv.git
OR
download a release and extract it.
tar xvfz libfnv*tar*
cd into the extracted directory:
cd libfnv*
Use ls to find out if there is a configure script.
ls -l configure
If not, run:
./autogen
Once the configure script is available, compilation is as normal for all autoconf enabled projects:
./configure
make
sudo make install
Compiling and Running your Own Programs
Once the package is installed, it may easily be compiled and linked with:gcc my_prog.c -o my_prog --static `pkg-config --libs --cflags libfnv`
In C, the library follows standard conventions. my_prog.c can be as simple as:
#include <stdio.h>
#include <fnv.h>
int main(int argc, char **argv) {
const char *test_string = "foobar";
uint64_t hval;
char result[17];
fnv64Init(&hval);
fnv64UpdateBuffer(&hval, test_string, 6);
fnv64ResultHex(result, &hval);
printf("%s\n", result);
return 0;
}
After you have compiled the example program above, you may try running it to verify the results of computing the 64-bit FNV-1a hash of the 6-byte string foobar.
./my_prog
Prepackaged Command Line Tools
This library includes a set of command line tools that may be used to compute FNV-1a hashes in any size. Simply select a bit size from 32, 64, 128, 256, 512, or 1024 and enter a command:fnv64sum [FILE]
All four bit sizes are supported with the corresponding command names.
To test or verify your own FNV implementation, you may use this library or another one such as this online FNV hash calculator.
On a modern consumer-grade computer, this library is able to process about a gigabyte of data per second using fnv32sum and fnv64sum, or about 100 megabytes per second using fnv128sum or fnv256sum.