ztools

package
v0.0.0-...-032b0eb Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2020 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHAR_SET               = "UTF-8"
	BASE_64_FORMAT         = "UrlSafeNoPadding"
	RSA_ALGORITHM_KEY_TYPE = "PKCS8"
	RSA_ALGORITHM_SIGN     = crypto.SHA256
)

Variables

This section is empty.

Functions

func Base64decode

func Base64decode(str string) ([]byte, error)

func Base64encode

func Base64encode(src []byte) string

func CancelTargetStr

func CancelTargetStr(str, substr string) string

func CreatCancelLineUuid

func CreatCancelLineUuid() string

func CreatUuidv4

func CreatUuidv4() string

func CreateKeys

func CreateKeys(publicKeyWriter, privateKeyWriter io.Writer, keyLength int) error

生成密钥对

func GenRSAKey

func GenRSAKey(size int) (privateKeyBytes, publicKeyBytes []byte, err error)

* 生成RSA密钥对

func GetCpuNum

func GetCpuNum() (int, error)

func GetCpuPercent

func GetCpuPercent() float64

func GetDiskPercent

func GetDiskPercent() float64

func GetDistrictUnixNanoTime

func GetDistrictUnixNanoTime(t time.Time) int64

获取区间时间

func GetDistrictUnixTime

func GetDistrictUnixTime(t time.Time) int64

func GetFileMd5

func GetFileMd5(path string) (string, error)

获取经过base64处理的md5值

func GetFirstMacAddr

func GetFirstMacAddr() (string, error)

func GetFreeMemory

func GetFreeMemory() uint64

func GetLastProofQueueData

func GetLastProofQueueData() interface{}

func GetNowUnixNanoTime

func GetNowUnixNanoTime() int64

func HttpRequest

func HttpRequest(url, ContentType string, method HttpMethod, v io.Reader, header map[string]string) ([]byte, error)

将数据发送出去 HttpRequest ...

func MarshalPKCS8PrivateKey

func MarshalPKCS8PrivateKey(key *rsa.PrivateKey) []byte

func RsaDecrypt

func RsaDecrypt(src, privateKeyBytes []byte) (bytesDecrypt []byte, err error)

* 私钥解密

func RsaDecryptBlock

func RsaDecryptBlock(src, privateKeyBytes []byte) (bytesDecrypt []byte, err error)

* 私钥解密-分段

func RsaEncrypt

func RsaEncrypt(src, publicKeyByte []byte) (bytes []byte, err error)

* 公钥加密

func RsaEncryptBlock

func RsaEncryptBlock(src, publicKeyByte []byte) (bytesEncrypt []byte, err error)

* 公钥加密-分段

func TrunFloat

func TrunFloat(f float64, prec int) float64

@Description :截断小数位数 @parameter: prec:从第几位开始截断

Types

type HttpMethod

type HttpMethod int
const (
	Get HttpMethod = iota
	Post
	Put
	Delete
)

type Queue

type Queue struct {
	// contains filtered or unexported fields
}

Queue 队列

var (
	GlobalProofQueue *Queue
)

func New

func New() *Queue

Create a new queue

func (*Queue) Any

func (this *Queue) Any() bool

返回true队列不为空

func (*Queue) Len

func (this *Queue) Len() int

获取队列长度

func (*Queue) Peek

func (this *Queue) Peek() interface{}

返回队列顶端元素

func (*Queue) Pop

func (this *Queue) Pop() interface{}

出队操作

func (*Queue) Push

func (this *Queue) Push(v interface{})

入队操作

type XRsa

type XRsa struct {
	// contains filtered or unexported fields
}

func NewXRsa

func NewXRsa(publicKey []byte, privateKey []byte) (*XRsa, error)

func (*XRsa) PrivateDecrypt

func (r *XRsa) PrivateDecrypt(encrypted string) (string, error)

私钥解密

func (*XRsa) PublicEncrypt

func (r *XRsa) PublicEncrypt(data string) (string, error)

公钥加密

func (*XRsa) Sign

func (r *XRsa) Sign(data string) (string, error)

数据加签

func (*XRsa) Verify

func (r *XRsa) Verify(data string, sign string) error

数据验签

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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