Advertisement
yocky12k

generator imei

Sep 10th, 2023
894
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. function imei_gen() {
  2.     $str = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  3.     $sum = 0;
  4.     $final_digit = 0;
  5.     $t = 0;
  6.     $len_offset = 0;
  7.     $len = 15;
  8.     $issuer = "";
  9.     $rbi = array("01", "10", "30", "33", "35", "44", "45", "49", "50", "51", "52", "53", "54", "86", "91", "98", "99");
  10.     $random_index = rand(0, count($rbi) - 1);
  11.     $arr = str_split($rbi[$random_index]);
  12.     $str[0] = (int) $arr[0];
  13.     $str[1] = (int) $arr[1];
  14.     $pos = 2;
  15.  
  16.     while ($pos < $len - 1) {
  17.         $str[$pos++] = rand(0, 9);
  18.     }
  19.  
  20.     $len_offset = ($len + 1) % 2;
  21.  
  22.     for ($pos = 0; $pos < $len - 1; $pos++) {
  23.         if (($pos + $len_offset) % 2) {
  24.             $t = $str[$pos] * 2;
  25.             if ($t > 9) {
  26.                 $t -= 9;
  27.             }
  28.             $sum += $t;
  29.         } else {
  30.             $sum += $str[$pos];
  31.         }
  32.     }
  33.  
  34.     $final_digit = (10 - ($sum % 10)) % 10;
  35.     $str[$len - 1] = $final_digit;
  36.     $t = implode('', $str);
  37.     $t = substr($t, 0, $len);
  38.    
  39.     return $t;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement