#coding=utf-8
import uuid
import datetime
import os

import platform
import base64
import hashlib

XorKey = [0xB2, 0x09, 0xBB, 0x55, 0x93, 0x83, 0x03, 0x24]

def enc(src):
    j, result = 0, ""
    for s in src:
        result = result + hex(ord(s) ^ (XorKey[j]))[2:]
        j = (j + 1) % 8
    return result

sysstr = platform.system()
if (sysstr == "Windows"):
    import _winreg
    key = _winreg.OpenKey(
        _winreg.HKEY_LOCAL_MACHINE,
        "SOFTWARE\\Microsoft\\Cryptography",
        0,
        _winreg.KEY_READ | _winreg.KEY_WOW64_64KEY
    )
    result = _winreg.QueryValueEx(key, "MachineGuid")
    mac = result[0]
else:
    mac = ':'.join(['{:02x}'.format((uuid.getnode() >> i) & 0xff) for i in range(0,8*6,8)][::-1])

#path = '/auth/repairwin/v2/'
path = '/auth/pfwin/'
mac += 'ZZLY[' + path + ']2019-04-17'
mac = enc(mac)
mac = base64.b64encode(mac)
mac = hashlib.sha256(mac).hexdigest()

cmd = 'echo ' + mac + '| clip'
os.system(cmd)

print u'#==================================修管佳=================================='
print '#'
print u'#机器码：　', mac
print '#'
print u'#系统时间：',datetime.datetime.now()
print '#'
print '#机器码已复制，可直接粘贴发送给授权人员'
print '#'
print u'#=============================郑州燎原版权所有============================='
print ''
os.system('pause')
