Java获取电脑硬件信息做license
生活随笔
收集整理的這篇文章主要介紹了
Java获取电脑硬件信息做license
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
項目做license,分為兩部部分:
一、一個小應用獲取電腦的硬件信息(硬件的CPU的ID,和主板信息)生成唯一標識碼
二、Java服務獲取應用信息,生成唯一標識碼,其他地方調用。
得到的字符串利用DES對其進行加密
.exe應用利用python寫一個簡單的獲取腳本:
ComputerUniqueCode.py
界面:ComputerUnique.py
import tkinter as tkfrom ComputerUniqueCode import ComputerUniqueCodewindow = tk.Tk() # 設置窗口的標題 window.title("電腦唯一碼") # 設置不可放大縮小 window.resizable(0, 0) # 設置窗口得到位置 # 得到屏幕寬度 sw = window.winfo_screenwidth() # 得到屏幕高度 sh = window.winfo_screenheight()# 得到屏幕高度 ww = 500 wh = 250x = (sw - ww) / 2 y = (sh - wh) / 2 window.geometry("%dx%d+%d+%d" % (ww, wh, x, y)) # 設置窗口大小 window.maxsize(ww, wh) window.minsize(ww, wh)# 設置結果顯示文本 result_data_Text = tk.Text(window, width=70, height=12) # 標簽長寬 # 在窗口中放置結果顯示文本 result_data_Text.pack()# 獲取按鈕點擊事件 def hit_me():cuc = ComputerUniqueCode()result_data_Text.insert(1.0, cuc.get_mcode())# 點擊按鈕 b = tk.Button(window,text='獲取', # 顯示在按鈕上的文字width=15, height=2,command=hit_me, activeforeground='white',activebackground='red') # 點擊按鈕式執行的命令# 在窗口中放置按鈕 b.pack(side=tk.RIGHT, padx=10, pady=10) # 進入消息循環 window.mainloop()打包用pyinstall,打包的時候注意python版本與os的版本的兼容性。
Java服務主要代碼:
pom.xml
<dependencies><dependency><groupId>net.java.dev.jna</groupId><artifactId>jna</artifactId><version>5.9.0</version></dependency><dependency><groupId>net.java.dev.jna</groupId><artifactId>jna-platform</artifactId><version>5.9.0</version></dependency><dependency><groupId>com.github.oshi</groupId><artifactId>oshi-core</artifactId><version>5.8.3</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-api</artifactId><version>1.7.32</version></dependency><dependency><groupId>org.slf4j</groupId><artifactId>slf4j-simple</artifactId><version>1.7.32</version></dependency><dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.7.15</version></dependency></dependencies>總結
以上是生活随笔為你收集整理的Java获取电脑硬件信息做license的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 十分钟深入理解const用法(趣味故事)
- 下一篇: thrift如何定义Java中的obje