欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

纯java获取CPU序列号,生成机器码

程序员文章站 2022-06-16 08:05:10
...

 

用于生成机器码

感觉用mac不靠谱,因为mac能改,

(除CPU序列号外,还可以获得主板序列号。)

 

public static void main(String[] args) {
	// TODO Auto-generated method stub
	try {
		long start = System.currentTimeMillis();
		Process process = Runtime.getRuntime().exec(
		new String[] { "wmic", "cpu", "get", "ProcessorId" });
		process.getOutputStream().close();
		Scanner sc = new Scanner(process.getInputStream());
		String property = sc.next();
		String serial = sc.next();
		System.out.println(property + ": " + serial);
		System.out.println("time:" + (System.currentTimeMillis() - start));
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}

}

 

ProcessorId: BFEBFBFF00030***

time:291

 

再用MD5加密下就成机器码了,不加密也行。

 

java MD5加密工具类

http://happyqing.iteye.com/blog/1771769

 

java RSA加密生成license

http://happyqing.iteye.com/blog/2083360

 

上一篇: springboot:mongodb

下一篇: springboot:amq