python - 我怎样才能“标记”一台计算机,以便以后在 Python 上识别它?
问题描述
我正在寻找一种在 Python 中“标记”计算机的方法,以便稍后为程序提供识别计算机的选项。
如您所知,我需要计算机中独一无二的东西,或者制作无法真正操纵的复杂东西。
为了更好地理解:
我实际上是在尝试防止在另一台计算机上使用具有相同数据的程序(我将在其中放置有关计算机的独特事物或信息)。
解决方案
它将为此使用 MAC 地址或主板 UUID。但是,MAC 地址不是每台计算机唯一的,而是每个网络接口唯一的。例如,当您更换网卡时,MAC 地址会发生变化。更多在 Python 中获取 MAC 地址的方法可以在这里找到。
from getmac import get_mac_address as gma
print(gma())
另一种看待这个的方式是;是什么让计算机与众不同?是网络设备、主板还是硬盘?或者也许是所有的组合?获取主板序列号的示例:
import os
import sys
os_type = sys.platform.lower()
if os_type.startswith('win'):
command = "wmic bios get serialnumber"
elif "linux" in os_type:
command = "hal-get-property --udi /org/freedesktop/Hal/devices/computer --key system.hardware.uuid"
elif "darwin" in os_type:
command = "ioreg -l | grep IOPlatformSerialNumber"
print(os.popen(command).read())
推荐阅读
- google-signin - 令牌验证文档中是否有错误?还是我弄错了?
- vba - POST 请求在 VBA (XML HTTP) 中不起作用
- javascript - InputText 并在一行中提交
- python - 通过python中的模拟退火找到噪声函数的全局最小值
- python - 减少python中3个循环的时间复杂度o(n ^ 3)
- jenkins - Kubernetes JNLP 上的 Jenkins 无法连接到 jenkins.example.de:50000
- reactjs - 如何将“智能动画”从 Figma 导出到 React/LottieFiles?
- scala - 在功能域设计中使用 Free Monad
- javascript - 如何使用授权令牌授权 Fetch 调用?
- haskell - 在 Archlinux 上设置 Haskell 的建议方法是什么?