scossdl_string_mod()WPSCache 1.0

Compute string modulo, based on SHA1 hash

No Hooks.

Return

Int. The remainder.

Usage

scossdl_string_mod( $str, $mod );
$str(string) (required)
The string.
$mod(int) (required)
The divisor.

scossdl_string_mod() code WPSCache 1.12.0

function scossdl_string_mod( $str, $mod ) {
	/**
	 * The full SHA1 is too large for PHP integer types.
	 * This should be enough for our purpose.
	 */
	$num = hexdec( substr( sha1( $str ), 0, 5 ) );

	return $num % $mod;
}