goaes

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2020 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertIV

func AssertIV(iv []byte)

判断AES向量长度是否合法

func AssertKey

func AssertKey(key []byte)

判断AES密钥长度是否合法

func PKCS7Padding

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

补码(AES算法PKCS#7和PKCS#5一致)

func PKCS7UnPadding

func PKCS7UnPadding(cihperData []byte) []byte

去码(AES算法PKCS#7和PKCS#5一致)

func Register

func Register(aesType AES_Mode, inst instance)

Types

type AES_Mode

type AES_Mode int
const (
	AES_Mode_CBC AES_Mode = 1 //CBC模式(密钥长度16/24/32字节)
	AES_Mode_CFB AES_Mode = 2 //CFB模式(密钥长度16/24/32字节)
	AES_Mode_ECB AES_Mode = 3 //ECB模式(密钥长度16/24/32字节)
	AES_Mode_OFB AES_Mode = 4 //OFB模式(密钥长度16/24/32字节)
	AES_Mode_CTR AES_Mode = 5 //CTR模式(密钥长度16/24/32字节)
)

func (AES_Mode) GoString

func (t AES_Mode) GoString() string

func (AES_Mode) String

func (t AES_Mode) String() string

type CryptoAES

type CryptoAES interface {
	//获取当前AES模式
	GetMode() AES_Mode
	//加密后返回二进制字节数据切片
	Encrypt([]byte) ([]byte, error)
	//加密后将密文做BASE64编码字符串
	EncryptBase64([]byte) (string, error)
	//解密后返回二进制字节数据切片
	Decrypt([]byte) ([]byte, error)
	//解密BASE64编码字符串的密文后返回二进制切片
	DecryptBase64(string) ([]byte, error)
}

func NewCryptoAES

func NewCryptoAES(aesType AES_Mode, key, iv []byte) CryptoAES

aesType AES加密模式 key 长度必须为16/24/32字节(128/192/256 bits) iv 向量长度固定16字节(ECB模式可传nil)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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