TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
- 网卡的物理地址即Mac地址一般都采用6字节48bit,前24位是由生产厂家向IEEE申请的
- 厂商地址,后24位就由生产厂家自行定。对于每一块网卡是惟一的。
- 下面程序中的aKey为网卡物理地址的十进制域十六进制值。
- public class getActiveKey {
- public static void main(String[] args){
- getActiveKey tkey=new getActiveKey();
- System.out.println(tkey.getRegKey(0x0040CABF85D5l));
- }
- public String getRegKey(long aKey) {
- if (aKey<=0)
- aKey=76649179349l;
- char[] aKeyChars = { 49, 87, 89, 90, 86, 50, 74, 78, 88, 82, 72, 51,
- 79, 73, 71, 53, 67, 52, 80, 54, 65, 76, 55, 85, 70, 56, 83, 69,
- 68, 57, 84, 66, 48, 81, 75, 77 };
- StringBuffer result;
- byte[] keyBytes;
- int patternLength;
- int keyCharsOffset;
- int i;
- int j;
- result = new StringBuffer("#####-#####-#####-#####-#####");
- keyBytes = String.valueOf(aKey).getBytes();
- patternLength = result.length();
- keyCharsOffset = 0;
- i = 0;
- j = 0;
- while ((i < keyBytes.length) && (j < patternLength)) {
- keyCharsOffset = keyCharsOffset + Math.abs(keyBytes[i]);
- while (keyCharsOffset >= aKeyChars.length) {
- keyCharsOffset = keyCharsOffset - aKeyChars.length;
- }
- while ((result.charAt(j) != 35) && (j < patternLength)) {
- j++;
- }
- result.setCharAt(j, aKeyChars[keyCharsOffset]);
- if (i == (keyBytes.length - 1)) {
- i = -1;
- }
- i++;
- j++;
- }
- //System.out.println(result.toString());
- return result.toString();
- }
- }
- 运行结果:
- C:java>java getActiveKey
- GQ4BG-M50GD-2AK4W-5K6MC-KO8VP
复制代码
源码下载:http://file.javaxxz.com/2014/10/2/092746672.zip |
|