crypto

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PublicKey = `` /* 1597-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func AESCBCDecrypt

func AESCBCDecrypt(key []byte, decodeBytes []byte) (string, error)

AESCBCDecrypt from base64 to decrypted string

func AESCBCEncrypt

func AESCBCEncrypt(key []byte, encodeStr string) ([]byte, error)

func AESCBCEncryptZeroIV

func AESCBCEncryptZeroIV(plaintext []byte) ([]byte, error)

func HmacSha256

func HmacSha256(secret string, message string) (string, error)

func PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func RSAVerifySignWithSha256

func RSAVerifySignWithSha256(publicKey []byte, origData []byte, signData string) error

func Sha256

func Sha256(origData []byte) []byte

Types

type Key

type Key struct {
	Id           string `json:"id"`            //密钥id
	KeyExp       int64  `json:"key_exp"`       //ignore,unix timestamp,密钥过期时间
	KeyEffective int64  `json:"key_effective"` //ignore,unix timestamp,密钥生效日期
	KeyString    string `json:"key_string"`    //密钥base64编码
	Version      uint   `json:"version"`       //密钥版本号(从0开始)
	KeyType      string `json:"key_type"`      //ignore,密钥种类
	KeyStatus    int    `json:"key_status"`    //ignore,密钥状态, 0为可用
	KeyDigest    string `json:"key_digest"`    //密钥digest(SHA256),客户端可以校验密钥完整性
}

type KeyStore

type KeyStore struct {
	CurrentKeyVersion uint   `json:"current_key_version"` //最新密钥版本号
	Service           string `json:"service"`             //服务识别码
	GrantUsage        string `json:"grant_usage"`         //ignore,密钥权限,E为加密,D为解密
	Keys              []Key  `json:"keys"`                //加解密密钥,可能是多个
}

func (*KeyStore) GetCurrentKey

func (this *KeyStore) GetCurrentKey() (Key, bool)

func (*KeyStore) GetFirstKey

func (this *KeyStore) GetFirstKey() (Key, bool)

func (*KeyStore) GetKey

func (this *KeyStore) GetKey(keyId string) (Key, bool)

Jump to

Keyboard shortcuts

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