OkamiFeng 发表于 2023-1-3 22:49

如何用Python实现激活码验证功能

我的需求是,我能生成激活码,激活码分发给用户,用户使用激活码激活软件使用。
1. 用户没有激活码无法运行软件
2. 绑定硬件,无法更换其他设备
3. 无法多开
4. 无法在虚拟机上运行

pwp 发表于 2023-1-4 03:18

这个东西不花钱是解决不了的,发一个悬赏

adx123456 发表于 2023-1-4 06:06

我觉得你最好的办法就是去程序员外包平台发个外包

Asra 发表于 2023-1-4 08:57

去猪八戒,众包这类外包网发个需求吧,你这样是没有人会帮做的

cf48rty 发表于 2023-1-4 09:23

为了实现这个功能,你可以使用 Python 的 hashlib 库来生成激活码。可以将激活码和用户的硬件信息(例如硬盘序列号)哈希,并将哈希值存储在服务器上,然后在用户试图激活软件时检查它们的硬件信息。为了防止用户多开,你可以使用操作系统的进程管理功能来统计软件正在运行的实例数,并限制这个数字。为了防止在虚拟机上运行,你可以检查虚拟机的标志(例如 CPUID)。

cf48rty 发表于 2023-1-4 09:26

使用 hashlib 库生成激活码并使用硬件信息将其绑定到用户的设备上代码示例:
import hashlib
import getpass
import platform

def generate_activation_code(hardware_info):
"""
Generates an activation code based on the user's hardware information.
"""
# Use the hashlib library to generate a hash of the hardware information
activation_code = hashlib.sha256(hardware_info.encode())
# Return the hexadecimal representation of the hash
return activation_code.hexdigest()

def bind_activation_code(activation_code, username):
"""
Binds the activation code to the user's account by storing it in a database.
"""
# Store the activation code in a database, associating it with the user's account
pass

def check_activation_code(activation_code, username):
"""
Checks the activation code for a user.
"""
# Retrieve the stored activation code for the user from the database
stored_activation_code = ""# Replace with code to retrieve activation code from database
# Check if the activation codes match
if activation_code == stored_activation_code:
    # Activation code is valid
    return True
else:
    # Activation code is invalid
    return False

def get_hardware_info():
"""
Returns a string containing the user's hardware information.
"""
# Get the username
username = getpass.getuser()
# Get the hostname
hostname = platform.node()
# Get the system information
system_info = platform.system()
# Return the hardware information as a string
return f"{username}:{hostname}:{system_info}"

def main():
# Get the user's hardware information
hardware_info = get_hardware_info()
# Generate an activation code based on the hardware info
activation_code = generate_activation_code(hardware_info)
# Bind the activation code to the user's account
bind_activation_code(activation_code, getpass.getuser())
# Prompt the user to enter their activation code
entered_code = input("Please enter your activation code: ")
# Check the activation code
if check_activation_code(entered_code, getpass.getuser()):
    # Activation code is valid, allow the user to run the software
    print("Activation successful, welcome!")
else:
    # Activation code is invalid, exit the software
    print("Activation code is invalid, exiting.")

if __name__ == "__main__":
main()

FIzz001 发表于 2023-1-4 10:15

大概用money就能解决

kkoo 发表于 2023-1-4 10:53

可能要外包给专业人员开发

甜萝 发表于 2023-1-4 11:36

你说的 1 23 4 这四点 都可以绕过

feiyu361 发表于 2023-1-4 12:25

可以用c实现
页: [1]
查看完整版本: 如何用Python实现激活码验证功能