licence

package module
v0.1.7 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 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月
	Months = "123456789XAB"
	// 日 "123456789ABCDEFGHJKMNPQRSTUVWXY" 分别代表 1-31 日
	Days = "123456789ABCDEFGHJKMNPQRSTUVWXY"
	// 日期显示格式
	DateFormat = "2006-01-02"
)
View Source
const (
	// 保留位
	Reserve = "00"
)

Variables

This section is empty.

Functions

func CreateActivationCode added in v0.1.2

func CreateActivationCode(machineCode string, date string, params Parameters, fixedCode string) (activationCode string, err error)

生成激活码

input:
	machineCode: 机器码
	       date: 日期 (Format: 2006-12-03)
	     params: 参数 (Struct: Parameters)
	  fixedCode: 固定码
output:
	activationCode: 激活码 (XXXX-XXXX-XXXX)
	           err: 异常信息

func CreateQRCode added in v0.1.6

func CreateQRCode(qr QRCode, fixedCode string) (batchCode string, codeList []string, err error)

根据玻片批次码,批量生产二维码数据

func GetMachineCode

func GetMachineCode(fixedcode string) string

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

func Hex2Bin added in v0.1.2

func Hex2Bin(hex string) string

16进制转二进制

func VerifyDate added in v0.1.7

func VerifyDate(date string) bool

检查日期格式

2006-12-03

Types

type Categorys added in v0.1.6

type Categorys int
const (
	Category_B Categorys = iota
	Category_P
	Category_K
	Category_L
	Category_Y
	Category_R
)

func GetCategory added in v0.1.6

func GetCategory(c string) Categorys

func (Categorys) String added in v0.1.6

func (c Categorys) String() string

type Parameters added in v0.1.5

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

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: 异常信息

func (Parameters) BinString added in v0.1.7

func (p Parameters) BinString() string

func (Parameters) HexString added in v0.1.7

func (p Parameters) HexString() string

type QRCode added in v0.1.6

type QRCode struct {
	Type     Types     // 类型:Z- 批次号 Q- 二维码标签号
	Batch    int       // 二维码批次号
	No       int       // Type=Z: 本批次生成二维码的数量; Type=Q: 二维码的序号
	Category Categorys // 二维码对应样本类型
	UseTimes int       // 限制二维码扫描的次数
}

玻片批次码/二维码内容 数据参数类型

func CheckQRCode added in v0.1.6

func CheckQRCode(qrcode string, fixedCode string) (status bool, qr QRCode, err error)

检验标签码

input:
	   qrcode: 标签码字符串
	fixedCode: 固定码
output:
	status: 检验状态
	    qr: 标签码 (Struct: QRCode)
	   err: 异常状态信息

func (QRCode) String added in v0.1.6

func (qr QRCode) String(fixedCode string) string

type Types added in v0.1.6

type Types int
const (
	Type_Batch Types = iota
	Type_Label
)

func GetType added in v0.1.6

func GetType(t string) Types

func (Types) String added in v0.1.6

func (t Types) String() string

Jump to

Keyboard shortcuts

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