aes

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2026 License: Apache-2.0 Imports: 4 Imported by: 15 modules, 44 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CBCDecrypt

func CBCDecrypt(secretData, key, iv []byte) ([]byte, error)

AES-CBC 解密数据

iv 长度不得小于一个分组(16 字节),secretData 长度必须为分组长度的非零整数倍。

func CBCEncrypt

func CBCEncrypt(originData, key, iv []byte) ([]byte, error)

AES-CBC 加密数据

iv 长度不得小于一个分组(16 字节),超出部分会被忽略。

func ECBDecrypt

func ECBDecrypt(secretData, key []byte) ([]byte, error)

AES-ECB 解密数据

secretData 长度必须为分组长度(16 字节)的非零整数倍。

func ECBEncrypt

func ECBEncrypt(originData, key []byte) ([]byte, error)

AES-ECB 加密数据

func GCMDecrypt

func GCMDecrypt(cipherText, nonce, additional, key []byte) ([]byte, error)

AES-GCM 解密数据

nonce 长度必须等于 GCM 标准 nonce 长度(12 字节),否则返回错误。

func GCMEncrypt

func GCMEncrypt(originText, nonce, additional, key []byte) (cipherText []byte, err error)

AES-GCM 加密数据

nonce 长度必须等于 GCM 标准 nonce 长度(12 字节),否则返回错误。

func PKCS5Padding

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

加密填充模式(添加补全码) PKCS5Padding 加密时,如果加密bytes的length不是blockSize的整数倍,需要在最后面添加填充byte

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

解密填充模式(去除补全码) PKCS5UnPadding 解密时,需要在最后面去掉加密时添加的填充byte

origData 为空、或填充数大于数据长度(数据未按 PKCS5 填充)时原样返回,不再越界 panic。

func PKCS7Padding

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

加密填充模式(添加补全码) PKCS5Padding 加密时,如果加密bytes的length不是blockSize的整数倍,需要在最后面添加填充byte

func PKCS7UnPadding

func PKCS7UnPadding(origData []byte) (bs []byte)

解密填充模式(去除补全码) PKCS7UnPadding 解密时,需要在最后面去掉加密时添加的填充byte

origData 为空、或填充数大于数据长度(数据未按 PKCS7 填充)时原样返回,不再越界 panic。

Types

This section is empty.

Jump to

Keyboard shortcuts

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