crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AesEncodeKeyLength = 43
)

Variables

This section is empty.

Functions

func GetAvoidLoginSignature

func GetAvoidLoginSignature(timestamp, secret string) string

GetAvoidLoginSignature 个人免登场景的签名计算方法 https://developers.dingtalk.com/document/app/signature-calculation-for-logon-free-scenarios-1

func GetSignature

func GetSignature(timestamp, secret string, ticket string) string

GetSignature 第三方访问接口的签名计算方法 https://developers.dingtalk.com/document/app/signature-calculation-method-for-third-party-access-interfaces-1

func RandomString

func RandomString(length int) string

RandomString 随机字符串

Types

type DingTalkCrypto

type DingTalkCrypto struct {

	// 签名 token
	Token string

	// 小程序的key
	SuiteKey string

	// 加密 aes_key
	AESKey []byte

	Block cipher.Block
}

func (*DingTalkCrypto) CreateSignature

func (c *DingTalkCrypto) CreateSignature(token, encrypt, timestamp, nonce string) string

CreateSignature 数据签名

func (*DingTalkCrypto) Decrypt

func (c *DingTalkCrypto) Decrypt(encrypt, sign, timestamp, nonce string) (string, error)

Decrypt 解密

func (*DingTalkCrypto) DecryptToByte

func (c *DingTalkCrypto) DecryptToByte(encrypt, sign, timestamp, nonce string) ([]byte, error)

func (*DingTalkCrypto) Encrypt

func (c *DingTalkCrypto) Encrypt(msg string) (*DingTalkEncrypt, error)

Encrypt 加密

func (*DingTalkCrypto) GetEncryptMsgDetail

func (c *DingTalkCrypto) GetEncryptMsgDetail(msg, timestamp, nonce string) (string, string, error)

func (*DingTalkCrypto) RandomString

func (c *DingTalkCrypto) RandomString(length int) string

RandomString 随机字符串

func (*DingTalkCrypto) VerificationSignature

func (c *DingTalkCrypto) VerificationSignature(encrypt, sign, timestamp, nonce string) bool

VerificationSignature 验证数据签名

type DingTalkEncrypt

type DingTalkEncrypt struct {

	// 加密体
	Encrypt string `json:"encrypt,omitempty"`

	// 签名
	Sign string `json:"msg_signature,omitempty"`

	// 时间戳
	Timestamp string `json:"timeStamp,omitempty"`

	// 随机字符串
	Nonce string `json:"nonce,omitempty"`
}

DingTalkEncrypt 钉钉事件回调加密

func NewDingTalkEncrypt

func NewDingTalkEncrypt(encrypt, sign, timestamp, nonce string) *DingTalkEncrypt

NewDingTalkEncrypt 钉钉返回体

func (*DingTalkEncrypt) String

func (d *DingTalkEncrypt) String() string

String 转换成json格式

Jump to

Keyboard shortcuts

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