LLMS_Hasher::hash( int $num )

Hash a number


Parameters Parameters

$num

(int) (Required) number to hash


Top ↑

Return Return

(string)


Top ↑

Source Source

File: includes/class.llms.hasher.php

	public static function hash( $num ) {

		$numlen = strlen( $num );
		if ( $numlen <= 3 ) {
			$len = 3;
		} elseif ( 4 === $numlen || 5 === $numlen ) {
			$len = 4;
		} else {
			$len = 5;
		}

		$ceil   = pow( 62, $len );
		$primes = array_keys( self::$golden_primes );
		$prime  = $primes[ $len ];
		$dec    = self::mod( ( $num * $prime ), $ceil );
		$hash   = self::base62( $dec );
		return str_pad( $hash, $len, '0', STR_PAD_LEFT );

	}


Top ↑

Changelog Changelog

Changelog
Version Description
3.16.7 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.