toolkit

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: MIT Imports: 4 Imported by: 0

README

toolkit

go.dev reference

简介

封装了一些常用的工具包,逐步更新

安装
go get github.com/keepchen/toolkit
方法
  • 初始化
import "github.com/keepchen/toolkit"

kit := toolkit.NewToolkit()

字符串


  • 生成短信验证码
smsCode := kit.GenerateSMSCode(5)
  • 生成随机字符串
shuffleStr := kit.GenerateRandomString(5)
  • 验证手机号码
ok := kit.ValidatePhone("13890012345")

文件


  • 加压zip文件
fileList, err := kit.Unzip("xx.zip", "/data/")

加密


  • MD5加密
hashedStr := kit.MD5encode("123")
  • sha256-rsa
c := kit.SetPublicKey(pubKey).SetPrivateKey(privateKey)

//签名
sign, err := c.SignUsingSha256WithRsa([]byte("test string"))

//验签
err := c.VerifySignUsingSha256WithRsa([]byte("test string"), sign)

其他


  • gin跨域设置
...
var r *gin.Engine
r.Use(kit.StartCors("", nil))
...

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Toolkit

type Toolkit struct {
	cors.Cors
	file.File
	strings.Strings
	crypt.Crypto
}

Toolkit 结构体

func NewToolkit

func NewToolkit() *Toolkit

NewToolkit 实例化

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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