Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
PHP extension to run djb2 hash from C
C PHP
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
tests
CREDITS
EXPERIMENTAL
README
chumash.c
chumash.php
config.m4
config.w32
php_chumash.h

README

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.
Something went wrong with that request. Please try again.