fix: reencrypt licence use aes
| | |
| | | package licence |
| | | |
| | | import ( |
| | | "encoding/base64" |
| | | "encoding/json" |
| | | "io/ioutil" |
| | | "os" |
| | | "time" |
| | | ) |
| | | |
| | | /* |
| | | 1.0.0 采集机器码, 授权日期 然后 AES 加密, 生成Licence, 秘钥会暴露给客户端 |
| | | 1.0.1 修改为RSA 非对称加密, 公钥开放. 加密内容为{注册码{机器码+公司+邮箱+手机}+过期时间+授权时间} |
| | | 1.0.2 修改Licence文件内容最终为AES加密后的内容, 然后再由公钥解密. 上个版本的bug, 仅使用非对称加密, 用户可以替换公钥 |
| | | */ |
| | | type RegisterCode struct { |
| | | MachineCode string |
| | | Company string |
| | |
| | | ValidationErrorExpired // Signature expired |
| | | ValidationErrorMalformed |
| | | |
| | | Version = "1.0.1" |
| | | Version = "1.0.2" |
| | | aesKey = "www.aiotlink.com" |
| | | ) |
| | | |
| | |
| | | return "", err |
| | | } |
| | | |
| | | licenceText := base64.StdEncoding.EncodeToString(licenceHex) |
| | | |
| | | return licenceText, nil |
| | | return AESEncodeStr(licenceHex, aesKey), nil |
| | | } |
| | | |
| | | func DecryptLicence(licencePath, publicKeyPath string) ([]byte, error) { |
| | |
| | | return nil, err |
| | | } |
| | | |
| | | licenceHex, _ := base64.StdEncoding.DecodeString(string(licenceCode)) |
| | | licenceHex := AESDecodeStr(string(licenceCode), aesKey) |
| | | |
| | | return RSA.PubKeyDECRYPT(licenceHex) |
| | | } |