licence

package module
v0.1.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 13 Imported by: 0

README

licence

Description

Go 版序列号

Installation
go get gitee.com/eshax/licence
Usage
  • go.mod
module licence.test

go 1.19

require gitee.com/eshax/licence v0.1.3
  • main.go
package main

import (
    "os"
    "gitee.com/eshax/licence"
)

func main() {

    //
    // 固定码(项目内自定义)
    //
    fixedCode := "test"


    //
    // 查询机器码, 根据当前程序所在的硬件环境计算机器码
    // 
    MachineCode := licence.GetMachineCode(fixedCode)


    //
    // 生成激活码, 根据已知某个服务器的机器码后, 附加限制日期以及参数后, 生成激活码
    //
    date := "2023-12-31"
    param := "1000000000000011"
    machineCode := "BM26H8L9"
    ActivationCode, err := licence.CreateActivationCode(machineCode, date, param, fixedcode)


    //
    // 验证激活码, 当前服务器验证序列号
    //
    activationCode := "23BY-8003-BM29"
    activationStatus, err := CheckActivationCode(activationCode, fixedCode)
}

Documentation

Index

Constants

View Source
const (
	// 月 "123456789XAB" 分别代表 1-12月
	MonthEnum = "123456789XAB"
	// 日 "123456789ABCDEFGHJKMNPQRSTUVWXY" 分别代表 1-31 日
	DayEnum = "123456789ABCDEFGHJKMNPQRSTUVWXY"
	// 日期显示格式
	DateFormat = "2006-01-02"
)

Variables

This section is empty.

Functions

func Bin2Hex added in v0.1.2

func Bin2Hex(bin string) (string, error)

二进制转16进制

func CreateActivationCode added in v0.1.2

func CreateActivationCode(machinecode string, date string, param string, fixedcode string) (string, error)

获取激活码

func DecryptDate added in v0.1.2

func DecryptDate(encryptedDate string) (string, error)

日期解密

func EncryptDate added in v0.1.2

func EncryptDate(date string) (string, error)

日期加密

func GetCheckCode added in v0.1.2

func GetCheckCode(fixedcode string, date string, param string) (string, error)

获取校验码

func GetMachineCode

func GetMachineCode(fixedcode string) string

获取机器码 @param fixedcode 参与MD5计算

func Hex2Bin added in v0.1.2

func Hex2Bin(hex string) (string, error)

16进制转二进制

Types

type Parameters added in v0.1.5

type Parameters struct {
	Testing        bool // true:测试版 false:正式版
	UseQRCode      bool // true:强制使用玻片二维码
	UseQRCodeCount int  // 允许使用二维码的次数
	AllowBM        bool // true:允许BM
	AllowPB        bool // true:允许PB
}

func CheckActivationCode added in v0.1.2

func CheckActivationCode(activationCode string, fixedcode string) (status bool, date string, parameters Parameters, err error)

验证激活码

input:
	activationcode: 激活码
	     fixedcode: 固定码
output:
	    status: 激活状态
	      date: 到期日期
	parameters: 参数
	       err: 异常信息

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL