Documentation
¶
Index ¶
- Variables
- func AesDecryptCBC(encrypted, key, iv []byte) (decrypted []byte, err error)
- func AesEncryptCBC(origData, key, iv []byte) (encrypted []byte, err error)
- func BytesToStr(b []byte) string
- func Contains(str string, s []string) bool
- func DecodePemHexBase64(keyStr string) ([]byte, error)
- func FileCopy(source, dest string) (err error)
- func FileExist(file string) bool
- func FileFindPath(fname string) (string, error)
- func FileIsBinary(content string) bool
- func FileIsDir(path string) bool
- func FileMove(src, dest string) error
- func FileSize(path string) int64
- func FormatByStr(tpl string, t int64) string
- func GenerateBase64Key(secretLength SecretKeyLengthType, secretFormat SecretKeyFormatType) (pkStr, pbkStr string, err error)
- func GetMonthRange(year, month int) (beginTime, endTime int64, err error)
- func GetWeek(t time.Time) int
- func IDInt64() int64
- func IDString() string
- func MacAddr() (upMac []string, err error)
- func ParsePrivateKey(derBytes []byte) (privateKey *rsa.PrivateKey, err error)
- func ParsePublicKey(derBytes []byte) (publicKey *rsa.PublicKey, err error)
- func RandAlphaString(length int) string
- func RandBytes(length int) []byte
- func RandInt(min, max int) int
- func RandInt32(min, max int32) int32
- func RandInt64(min, max int64) int64
- func RandInts(from, to, size int) []int
- func RandLower(l int) string
- func RandString(n int) string
- func RandUpper(l int) string
- func RsaPrivateDecrypt(privateKeyStr string, cipherBytes []byte) (textBytes []byte, err error)
- func RsaPublicEncrypt(publicKeyStr string, textBytes []byte) ([]byte, error)
- func SignByRSA(key *rsa.PrivateKey, licenseBytes []byte) (license string, err error)
- func SignByRSABytes(key, licenseBytes []byte) (string, error)
- func SignBySM2(privateKey *sm2.PrivateKey, licenseBytes []byte) (license string, err error)
- func SignBySM2Bytes(privateKey, licenseBytes []byte) (license string, err error)
- func StrToBytes(str string) []byte
- func StringReplaceIgnoreCase(text, source, target string) string
- func TimeToStr(t time.Time, format ...string) string
- func TimestampToStr(t int64, format ...string) string
- func VerifyByRSA(publicKeyBase64, licenseCode string) (license string, valid bool, err error)
- func VerifyBySM2(publicKeyBase64, licenseCode string) (license string, valid bool, err error)
- type SecretKeyFormatType
- type SecretKeyLengthType
- type Time
Constants ¶
This section is empty.
Variables ¶
Epoch is 01/01/1970.
Functions ¶
func AesDecryptCBC ¶
AesDecryptCBC cbc模式解密
func AesEncryptCBC ¶
AesEncryptCBC 加密 AES-128。key长度:16, 24, 32 bytes 对应 AES-128, AES-192, AES-256
func DecodePemHexBase64 ¶
DecodePemHexBase64 解析pem或者hex或者base64编码成der编码
func FileFindPath ¶
FileFindAPath 获取文件名路径,首先判断文件是否可以直接访问,优先获取当前可执行文件夹下,再去找工作路径下。
func FormatByStr ¶
FormatByStr 将字符串中的时间变量(y年/m月/d日/h时/i分/s秒)转换成时间字符串
func GenerateBase64Key ¶
func GenerateBase64Key(secretLength SecretKeyLengthType, secretFormat SecretKeyFormatType) (pkStr, pbkStr string, err error)
GenerateBase64Key 生成base64编码的公私钥
func GetMonthRange ¶
GetMonthRange 获得指定年份和月份的起始unix时间和截止unix时间
func ParsePrivateKey ¶
func ParsePrivateKey(derBytes []byte) (privateKey *rsa.PrivateKey, err error)
ParsePrivateKey 解析私钥,derBytes可以使用DecodePemHexBase64函数获取
func ParsePublicKey ¶
ParsePublicKey 解析公钥,derBytes可以使用DecodePemHexBase64函数获取
func RsaPrivateDecrypt ¶
RsaPrivateDecrypt 解析rsa私钥,参数privateKeyStr必须是hex、base64或者是pem编码
func RsaPublicEncrypt ¶
RsaPublicEncrypt Rsa公钥加密,参数publicKeyStr必须是hex、base64或者是pem编码
func SignByRSA ¶
func SignByRSA(key *rsa.PrivateKey, licenseBytes []byte) (license string, err error)
SignByRSA 使用rsa私钥对象指针签名字符串,返回base64编码的license
func SignByRSABytes ¶
SignByRSABytes 使用rsa私钥签名字符串,返回base64编码的license
func SignBySM2 ¶
func SignBySM2(privateKey *sm2.PrivateKey, licenseBytes []byte) (license string, err error)
SignBySM2 使用sm2私钥对象指针签名字符串,返回base64编码的license
func SignBySM2Bytes ¶
SignBySM2Bytes 使用sm2私钥签名字符串,返回base64编码的license
func StringReplaceIgnoreCase ¶
StringReplaceIgnoreCase 忽略大小写替换字符串
func VerifyByRSA ¶
VerifyByRSA 使用rsa公钥验证签名的license
Types ¶
type SecretKeyFormatType ¶
type SecretKeyFormatType int
const ( PKCS8 SecretKeyFormatType = 1 PKCS1 SecretKeyFormatType = 2 )
func SecretKeyFormatTypeParse ¶
func SecretKeyFormatTypeParse(v int) SecretKeyFormatType
type SecretKeyLengthType ¶
type SecretKeyLengthType int
const ( RSA SecretKeyLengthType = 1 M2 SecretKeyLengthType = 2 )
func SecretKeyLengthTypeParse ¶
func SecretKeyLengthTypeParse(v int) SecretKeyLengthType
type Time ¶ added in v1.1.0
Time is the allowed format for time, as per the RFC 7519.
func NumericDate ¶ added in v1.1.0
NumericDate is a resolved Unix time.
func (Time) MarshalJSON ¶ added in v1.1.0
MarshalJSON implements a marshaling function for time-related claims.
func (*Time) UnmarshalJSON ¶ added in v1.1.0
UnmarshalJSON implements an unmarshaling function for time-related claims.