util

package
v0.0.0-...-cd6ae7c Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2024 License: CC0-1.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const Pkcs5Padding = "PKCS5" // PKCS5填充模式
View Source
const Pkcs7Padding = "PKCS7" // PKCS7填充模式
View Source
const ZEROSPadding = "ZEROS" // ZEROS填充模式

Variables

This section is empty.

Functions

func AesECBDecrypt

func AesECBDecrypt(ciphertext, key []byte, padding string) ([]byte, error)

AesECBDecrypt aes解密算法,ECB模式,可以指定三种填充模式

func AesECBEncrypt

func AesECBEncrypt(plaintext, key []byte, padding string) ([]byte, error)

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(src []byte, blockSize int) []byte

func PKCS5Unpadding

func PKCS5Unpadding(src []byte) ([]byte, error)

func PKCS7Padding

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

func PKCS7UnPadding

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

func Padding

func Padding(padding string, src []byte, blockSize int) []byte

func UnPadding

func UnPadding(padding string, src []byte) ([]byte, error)

func ZerosPadding

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

func ZerosUnPadding

func ZerosUnPadding(src []byte) ([]byte, error)

Types

type Crypto

type Crypto interface {
	Encrypt(plaintext string) (string, error)
	Decrypt(ciphertext string) (string, error)
}

func NewAesCrypto

func NewAesCrypto(key string) Crypto

func NewPrefixCrypto

func NewPrefixCrypto(prefix string, crypto Crypto) Crypto

Jump to

Keyboard shortcuts

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