gaes

package
v0.0.0-...-c4191a4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package gaes provides useful API for AES encryption/decryption algorithms.

Index

Constants

View Source
const (
	// IVDefaultValue is the default value for IV.
	IVDefaultValue = "I Love Go Frame!"
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(cipherText []byte, key []byte, iv ...[]byte) ([]byte, error)

Decrypt is alias of DecryptCBC.

func DecryptCBC

func DecryptCBC(cipherText []byte, key []byte, iv ...[]byte) ([]byte, error)

DecryptCBC decrypts `cipherText` using CBC mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.

func DecryptCFB

func DecryptCFB(cipherText []byte, key []byte, unPadding int, iv ...[]byte) ([]byte, error)

DecryptCFB decrypts `plainText` using CFB mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.

func Encrypt

func Encrypt(plainText []byte, key []byte, iv ...[]byte) ([]byte, error)

Encrypt is alias of EncryptCBC.

func EncryptCBC

func EncryptCBC(plainText []byte, key []byte, iv ...[]byte) ([]byte, error)

EncryptCBC encrypts `plainText` using CBC mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.

func EncryptCFB

func EncryptCFB(plainText []byte, key []byte, padding *int, iv ...[]byte) ([]byte, error)

EncryptCFB encrypts `plainText` using CFB mode. Note that the key must be 16/24/32 bit length. The parameter `iv` initialization vector is unnecessary.

func PKCS5Padding

func PKCS5Padding(src []byte, blockSize ...int) []byte

PKCS5Padding applies PKCS#5 padding to the source byte slice to match the given block size.

If the block size is not provided, it defaults to 8.

func PKCS5UnPadding

func PKCS5UnPadding(src []byte, blockSize ...int) ([]byte, error)

PKCS5UnPadding removes PKCS#5 padding from the source byte slice based on the given block size.

If the block size is not provided, it defaults to 8.

func PKCS7Padding

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

PKCS7Padding applies PKCS#7 padding to the source byte slice to match the given block size.

func PKCS7UnPadding

func PKCS7UnPadding(src []byte, blockSize int) ([]byte, error)

PKCS7UnPadding removes PKCS#7 padding from the source byte slice based on the given block size.

func ZeroPadding

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

func ZeroUnPadding

func ZeroUnPadding(plaintext []byte, unPadding int) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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