crypto

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptyContent = errors.New("encrpty plain content empty")
	ErrNotFull      = errors.New("crypto/cipher: input not full blocks")
)

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

func AesEncrypt

func AesEncrypt(src string, key []byte) ([]byte, error)

func MD5String

func MD5String(key string, length int) string

md5String 生成MD5前缀,截断 length 长度.

func NewECBDecrypter

func NewECBDecrypter(b cipher.Block) cipher.BlockMode

NewECBDecrypter returns a BlockMode which decrypts in electronic code book mode, using the given Block.

func NewECBEncrypter

func NewECBEncrypter(b cipher.Block) cipher.BlockMode

NewECBEncrypter returns a BlockMode which encrypts in electronic code book mode, using the given Block.

func PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func RandString

func RandString(length int) string

生成指定长度的随机字符串 https://colobu.com/2018/09/02/generate-random-string-in-Go/

Types

type Aes

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

func NewAes

func NewAes(cipher []byte) *Aes

func (*Aes) Decrypt

func (aes *Aes) Decrypt(crypted []byte) ([]byte, error)

func (*Aes) Encrypt

func (aes *Aes) Encrypt(src string) ([]byte, error)

Jump to

Keyboard shortcuts

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