A dual-shot class that completely maps to one in a given natural number space. it is reversible and cannot be guessed.
/***** 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 ;}}