-
Notifications
You must be signed in to change notification settings - Fork 0
igorclark/chumash
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
I wanted to use the djb2 hash function (http://www.cse.yorku.ca/~oz/hash.html) in PHP. It relies on unsigned long int overflows, but ints in PHP are fixed to 32-bit signed. So I created this wrapper extension. Largely to see how you write PHP wrappers. Fairly straightforward. Ultimately this might be a place to expose C implementations of various hash functions that aren't already implemented in PHP core (http://php.net/manual/en/ref.hash.php). To use it, check out into your php-5.x.x/ext source folder ($PHP_SOURCE), then: $ rm $PHP_SOURCE/configure $ cd $PHP_SOURCE $ ./buildconf --force $ make $ ./sapi/cli/php ./ext/chumash/chumash.php NB: the PHP function chumash_djb2() will stil return an unsigned long int forced into a signed 32-bit int, so it'll return potentially negative numbers. Use chumash_djb2_with_range to modulo the hash against your range, and all the unsigned stuff stays on the C side.
About
PHP extension to run djb2 hash from C
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published