cbc

package
v2.0.47 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: MIT Imports: 9 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenKeyBySHA1Hash2 added in v2.0.45

func GenKeyBySHA1Hash2(key string, keyLen AES_KEY_LEN) []byte

采用hmac进行2次hash, 取32位, 这样对key没有长度要求

func GenRandomKey added in v2.0.45

func GenRandomKey(keyLen AES_KEY_LEN) ([]byte, error)

func MustGenRandomKey added in v2.0.45

func MustGenRandomKey(keyLen AES_KEY_LEN) []byte

func PKCS7Padding added in v2.0.45

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

PKCS7Padding 对数据进行 PKCS#7 填充

func PKCS7Unpadding added in v2.0.45

func PKCS7Unpadding(origData []byte) []byte

PKCS7Unpadding 对数据进行 PKCS#7 去填充

Types

type AESCBCCihper added in v2.0.45

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

func MustNewAESCBCCihper added in v2.0.45

func MustNewAESCBCCihper(key []byte) *AESCBCCihper

func NewAESCBCCihper added in v2.0.45

func NewAESCBCCihper(key []byte) (*AESCBCCihper, error)

func (*AESCBCCihper) DecodeCipherText added in v2.0.45

func (c *AESCBCCihper) DecodeCipherText(cipherText string) (cipherData []byte, err error)

func (*AESCBCCihper) Decrypt added in v2.0.45

func (c *AESCBCCihper) Decrypt(encryptData []byte) ([]byte, error)

func (*AESCBCCihper) DecryptFromCipherText added in v2.0.45

func (c *AESCBCCihper) DecryptFromCipherText(cipherText string) (string, error)

func (*AESCBCCihper) Encrypt added in v2.0.45

func (c *AESCBCCihper) Encrypt(rawData []byte) ([]byte, error)

func (*AESCBCCihper) EncryptFromString added in v2.0.45

func (c *AESCBCCihper) EncryptFromString(rawString string) (string, error)

func (*AESCBCCihper) EncryptToString added in v2.0.45

func (c *AESCBCCihper) EncryptToString(rawData []byte) (string, error)

func (*AESCBCCihper) GenRandomIv added in v2.0.45

func (c *AESCBCCihper) GenRandomIv(cipherText []byte) ([]byte, error)

初始向量IV必须是唯一,但不需要保密, 这里随机生成一个block 作为IV向量

func (*AESCBCCihper) GetIv added in v2.0.45

func (c *AESCBCCihper) GetIv(encryptData []byte) []byte

func (*AESCBCCihper) GetIvFromCipherText added in v2.0.45

func (c *AESCBCCihper) GetIvFromCipherText(cipherString string) ([]byte, error)

func (*AESCBCCihper) MustGetIvFromCipherText added in v2.0.45

func (c *AESCBCCihper) MustGetIvFromCipherText(cipherString string) []byte

func (*AESCBCCihper) SetDataEncodeType added in v2.0.45

func (c *AESCBCCihper) SetDataEncodeType(v DATA_ENCODE_TYPE) *AESCBCCihper

type AES_KEY_LEN added in v2.0.45

type AES_KEY_LEN int

aesCBCEncrypt aes加密,填充秘钥key的16位,24,32分别对应AES-128, AES-192, or AES-256.

const (
	AES_KEY_LEN_16 AES_KEY_LEN = 16
	AES_KEY_LEN_24 AES_KEY_LEN = 24
	AES_KEY_LEN_32 AES_KEY_LEN = 32
)

type DATA_ENCODE_TYPE added in v2.0.45

type DATA_ENCODE_TYPE int
const (
	DATA_ENCODE_TYPE_HEX DATA_ENCODE_TYPE = iota
	DATA_ENCODE_TYPE_BASE64
)

Jump to

Keyboard shortcuts

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