encrypt

package
v0.0.0-...-325abe0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2019 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AES_ENCODE_KEY_LENGTH = 43
)

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(cryted string) (string, error)

func AesEncrypt

func AesEncrypt(orig string) (string, error)

func Base58Decode

func Base58Decode(b string) ([]byte, error)

Decode decodes a modified base58 string to a byte slice.

func Base58Encode

func Base58Encode(b []byte) string

Encode encodes a byte slice to a modified base58 string.

func Ddbase64sign

func Ddbase64sign(key string) (bt []byte, err error)

Base64解密

func PKCS7Padding

func PKCS7Padding(ciphertext []byte, blockSize int) []byte

func PKCS7UnPadding

func PKCS7UnPadding(plantText []byte) []byte

Types

type Crypto

type Crypto struct {
	Token    string
	AesKey   string
	SuiteKey string
	// contains filtered or unexported fields
}
var DefaultDingtalkCrypto *Crypto

func NewCrypto

func NewCrypto(token, aesKey, suiteKey string) (c *Crypto)

token 随机串 aesKey suiteKey 一般使用corpID

func (*Crypto) DecryptMsg

func (c *Crypto) DecryptMsg(signature, timeStamp, nonce, secretStr string) (string, error)

signature: 签名字符串 timeStamp: 时间戳 nonce: 随机字符串 secretStr: 密文 返回: 解密后的明文

func (*Crypto) EncryptMsg

func (c *Crypto) EncryptMsg(replyMsg, timeStamp, nonce string) (string, string, error)

replyMsg: 明文字符串 timeStamp: 时间戳 nonce: 随机字符串 返回: 密文,签名字符串

func (*Crypto) GenerateSignature

func (c *Crypto) GenerateSignature(token, timeStamp, nonce, secretStr string) string

数据签名

func (*Crypto) RandomString

func (c *Crypto) RandomString(n int, alphabets ...byte) string

func (*Crypto) VerifySignature

func (c *Crypto) VerifySignature(token, timeStamp, nonce, secretStr, sigture string) bool

校验数据签名

type Test

type Test struct {
	Content string
}

Jump to

Keyboard shortcuts

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