Skip to content

fnvhash/libfnv

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
lib
 
 
 
 
 
 
m4
 
 
man
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

Downloads of Releases

About

C library to calculate the FNV Hash function in 32, 64, 128, or 256 bits. The FNV-1a version is supported.

Resources

License

MIT, GPL-3.0 licenses found

Licenses found

MIT
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Packages

No packages published