隨機生成imei imsi mac


 1     private static String getIMEI() {// calculator IMEI
 2         int r1 = 1000000 + new java.util.Random().nextInt(9000000);
 3         int r2 = 1000000 + new java.util.Random().nextInt(9000000);
 4         String input = r1 + "" + r2;
 5         char[] ch = input.toCharArray();
 6         int a = 0, b = 0;
 7         for (int i = 0; i < ch.length; i++) {
 8             int tt = Integer.parseInt(ch[i] + "");
 9             if (i % 2 == 0) {
10                 a = a + tt;
11             } else {
12                 int temp = tt * 2;
13                 b = b + temp / 10 + temp % 10;
14             }
15         }
16         int last = (a + b) % 10;
17         if (last == 0) {
18             last = 0;
19         } else {
20             last = 10 - last;
21         }
22         return input + last;
23     }
24 
25     private static String getImsi() {
26         // 460022535025034
27         String title = "4600";
28         int second = 0;
29         do {
30             second = new java.util.Random().nextInt(8);
31         } while (second == 4);
32         int r1 = 10000 + new java.util.Random().nextInt(90000);
33         int r2 = 10000 + new java.util.Random().nextInt(90000);
34         return title + "" + second + "" + r1 + "" + r2;
35     }
36     private static String getMac(){
37         char[] char1 = "abcdef".toCharArray();
38         char[] char2 = "0123456789".toCharArray();
39         StringBuffer mBuffer = new StringBuffer();
40         for (int i = 0; i < 6; i++) {
41             int t = new java.util.Random().nextInt(char1.length);
42             int y = new java.util.Random().nextInt(char2.length);
43             int key = new java.util.Random().nextInt(2);
44             if (key ==0) {
45                 mBuffer.append(char2[y]).append(char1[t]);
46             }else {
47                 mBuffer.append(char1[t]).append(char2[y]);
48             }
49             
50             if (i!=5) {
51                 mBuffer.append(":");
52             }
53         }
54         return mBuffer.toString();
55     }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM