Using the principles of mass numbers and modulo operations, a given natural number space maps each natural number to another natural number, and the mapped natural number is mapped only by this natural number. It is mainly used to generate the natural number corresponding to the unguessed natural number that is evenly distributed in the natural number space corresponding to the auto-increment id. It is used for resource URIs with privacy protection such as express logistics bill number, order number, and image path.
Using the principles of mass numbers and modulo operations, a given natural number space maps each natural number to another natural number, and the mapped natural number is mapped only by this natural number. It is mainly used to generate the natural number corresponding to the unguessed natural number that is evenly distributed in the natural number space corresponding to the auto-increment id. It is used for resource URIs with privacy protection such as express logistics bill number, order number, and image path.
Using the principles of mass numbers and modulo operations, a given natural number space maps each natural number to another natural number, and the mapped natural number is mapped only by this natural number.
It is mainly used to generate the natural number corresponding to the unguessed natural number that is evenly distributed in the natural number space corresponding to the auto-increment id.
It is used for resource URIs with privacy protection such as express logistics bill number, order number, and image path.
<无>
/***** Double-shot class * completely maps one to one in a given natural number space, reversible operation, cannot be guessed * @ author liuxu **/class Bijective {static private $ defaultPrime = '000000 '; // use the prime number static public function getRandPrime () {return self: getMinPrime (rand (,) with a single digit of "3", "7", and "9) * 100000 + rand (100000,900000);} static public function getMinPrime ($ min) {$ number = $ min; while (true) {if (self :: isPrime ($ number) break; $ number ++;} return $ number;} static public function isPrime ($ number) {$ sqrt = intval (bcsqrt ($ number, 0); for ($ I = 2; $ I <= $ sqrt; $ I ++) {if (bcmod ($ number, $ I) === '0') {return false ;}} return true;} static public function mod ($ number, $ len = 10) {return bcmod (bcmul ($ number, self: $ defaprime Prime, 0), bcpow (10, $ len, 0);} static public function loop ($ number, $ len = 8) {$ min = $ prev = $ number; for ($ I = 1; $ I ++) {$ next = self: mod ($ prev, $ len ); if ($ next = $ number) break; $ min = min ($ min, $ next); $ prev = $ next;} $ offset = ($ min % $ I) + 1; for ($ j = 0; $ j <$ offset; $ j ++) {$ number = self: mod ($ number, $ len );} return $ number;} static public function insanity ($ number, $ len = 10) {$ number = self: mod ($ number, $ len ); $ number = str_pad ($ number, $ len, '0', STR_PAD_LEFT); $ numberList = str_split ($ number, 6 ); foreach ($ numberList as $ key => $ value) {$ numberList [$ key] = str_pad (self: loop ($ value, strlen ($ value )), strlen ($ value), '0', STR_PAD_LEFT);} $ number = implode ('', $ numberList); return $ number ;}}