package com.app.reg;
|
|
import java.io.BufferedReader;
|
import java.io.InputStreamReader;
|
import java.text.DecimalFormat;
|
import java.text.NumberFormat;
|
|
public class RegistCoade {
|
|
static public String getRegistSerialCoade(String usr, String id_num)
|
{
|
String mac = getMacOnWindow();
|
if(null == mac)
|
return null;
|
else return getSerial(usr, id_num, mac);
|
}
|
|
private static String getSerial(String userId, String licenseNum, String macaddr)
|
{
|
/*
|
Calendar cal = Calendar.getInstance();
|
cal.add(1, 1);
|
cal.add(6, -1);
|
String verTime = (new StringBuilder("-")).append(
|
(new SimpleDateFormat("yyMMdd")).format(cal.getTime())).append("0").toString();
|
*/
|
NumberFormat nf = new DecimalFormat("000");
|
licenseNum = nf.format(Integer.valueOf(licenseNum));
|
String type = "AMTB-";
|
String need = (new StringBuilder(userId.substring(0, 1))).append(type).append("300").append(
|
licenseNum)./*append(verTime).*/toString();
|
String dx = (new StringBuilder(need))
|
.append( "When Bodhisattva Avalokiteshvara was practicing the profound Prajna Paramita, he illuminated the Five Skandhas and saw that they are all empty, and he crossed beyond all suffering and difficulty."
|
+ "Shariputra, form does not differ from emptiness; emptiness does not differ from form. Form itself is emptiness; emptiness itself is form. "
|
+ "So too are feeling, cognition, formation, and consciousness."
|
+ "Shariputra, all Dharmas are empty of characteristics. They are not produced, not destroyed, not defiled, not pure; and they neither increase nor diminish. "
|
+ "Therefore, in emptiness there is no form, feeling, cognition, formation, or consciousness; "
|
+ "no eyes, ears, nose, tongue, body, or mind; no sights, sounds, smells, tastes, objects of touch, or Dharmas; "
|
+ "no field of the eyes up to and including no field of mind consciousness; "
|
+ "and no ignorance or ending of ignorance, up to and including no old age and death or ending of old age and death. "
|
+ "There is no suffering, no accumulating, no extinction, and no Way, and no understanding and no attaining."
|
+ "Because nothing is attained, the Bodhisattva through reliance on Prajna Paramita is unimpeded in his mind. "
|
+ "Because there is no impediment, he is not afraid, and he leaves distorted dream-thinking far behind. "
|
+ "Ultimately Nirvana! All Buddhas of the three periods of time attain Anuttara-samyak-sambodhi through reliance on Prajna Paramita. "
|
+ "Therefore know that Prajna Paramita is a Great Spiritual Mantra, a Great Bright Mantra, a Supreme Mantra, an Unequalled Mantra. "
|
+ "It can remove all suffering; it is genuine and not false. That is why the Mantra of Prajna Paramita was spoken. Recite it like this:"
|
+ "Gate Gate Paragate Parasamgate"
|
+ "Bodhi Svaha!"
|
+ macaddr )
|
.append(userId).toString();
|
int suf = decode(dx);
|
String code = (new StringBuilder(need)).append(String.valueOf(suf)).toString();
|
return change(code);
|
}
|
|
private static int decode(String s) {
|
int i = 0;
|
char ac[] = s.toCharArray();
|
int j = 0;
|
for (int k = ac.length; j < k; j++)
|
i = 31 * i + ac[j];
|
return Math.abs(i);
|
}
|
|
private static String change(String s) {
|
byte abyte0[] = s.getBytes();
|
char ac[] = new char[s.length()];
|
int i = 0;
|
for (int k = abyte0.length; i < k; i++) {
|
int j = abyte0[i];
|
if (j >= 48 && j <= 57)
|
j = ((j - 48) + 5) % 10 + 48;
|
else if (j >= 65 && j <= 90)
|
j = ((j - 65) + 13) % 26 + 65;
|
else if (j >= 97 && j <= 122)
|
j = ((j - 97) + 13) % 26 + 97;
|
ac[i] = (char) j;
|
}
|
return String.valueOf(ac);
|
}
|
|
private static String getMacOnWindow() {
|
try {
|
String mac = null;
|
Process process = Runtime.getRuntime().exec("ipconfig /all");
|
BufferedReader buffer = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
for (String line = buffer.readLine(); line != null; line = buffer.readLine())
|
{
|
if(line.contains("ÒÔÌ«ÍøÊÊÅäÆ÷ ±¾µØÁ¬½Ó") || line.contains("Ethernet adapter ±¾µØÁ¬½Ó")
|
|| line.contains("ÒÔÌ«ÍøÊÊÅäÆ÷ ÒÔÌ«Íø") || line.contains("Ethernet adapter ÒÔÌ«Íø")
|
|| line.contains("ÎÞÏß¾ÖÓòÍøÊÊÅäÆ÷ ±¾µØÁ¬½Ó")
|
|| line.contains("ÒÔÌ«ÍøÊÊÅäÆ÷ À¶ÑÀ"))
|
{
|
for (line = buffer.readLine(); line != null; line = buffer.readLine())
|
{
|
if(line.contains("ÎïÀíµØÖ·") || line.contains("Physical Address"))
|
{
|
mac = line;
|
break;
|
}
|
}
|
}
|
else
|
{
|
continue;
|
}
|
}
|
buffer.close();
|
process.waitFor();
|
return mac;
|
} catch (Exception exception) {
|
return null;
|
}
|
}
|
}
|