blockcipher

package
v0.0.0-...-f1279a5 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//ErrMODENotExists 加密解密的模式不存在
	ErrMODENotExists = errors.New("MODE错误")
	//ErrAESPasswordTolang AES加密的秘钥长度过长,超过了32位
	ErrAESPasswordTolang = errors.New("AES加密的秘钥长度过长")
	//ErrAESIVLength AES的iv长度默认为16
	ErrAESIVLength = errors.New("AES iv 长度错误")
	//ErrAESStreamIv 从数据流获取iv数据失败
	ErrAESStreamIv = errors.New("获取iv数据失败")
)

Functions

func AESCBCDecryption

func AESCBCDecryption(password string, ciphertext []byte) ([]byte, error)

AESCBCDecryption AES CBC解密

func AESCBCEncryption

func AESCBCEncryption(password string, plaintext []byte) ([]byte, error)

AESCBCEncryption AES CBC加密

func AESGCMDecryption

func AESGCMDecryption(password string, ciphertext []byte, nonce []byte) ([]byte, error)

AESGCMDecryption AES解密的GCM模式

func AESGCMEncryption

func AESGCMEncryption(password string, plaintext []byte, nonce []byte) ([]byte, []byte, error)

AESGCMEncryption AES加密的GCM模式

func AESPassword

func AESPassword(password string) []byte

AESPassword aes加密密钥处理,使用0进行填充

func AESStreamDecryption

func AESStreamDecryption(password string, mode MODE, ciphertext []byte) ([]byte, error)

AESStreamDecryption AES CFB/CTR/OFB

func AESStreamDecryptionFile

func AESStreamDecryptionFile(password string, mode MODE, inpath, outpath string) error

AESStreamDecryptionFile AES CFB/CTR/OFB 文件

func AESStreamDecryptionStream

func AESStreamDecryptionStream(password string, mode MODE, in io.Reader, out io.Writer) error

AESStreamDecryptionStream AES CFB/CTR/OFB 文件

func AESStreamEncryption

func AESStreamEncryption(password string, mode MODE, plaintext []byte) ([]byte, error)

AESStreamEncryption AES CFB/CTR/OFB

func AESStreamEncryptionFile

func AESStreamEncryptionFile(password string, mode MODE, inpath, outpath string) error

AESStreamEncryptionFile AES CFB/CTR/OFB 文件

func AESStreamEncryptionStream

func AESStreamEncryptionStream(password string, mode MODE, in io.Reader, out io.Writer) error

AESStreamEncryptionStream AES CFB/CTR/OFB 文件

func CBCCiphertext

func CBCCiphertext(ciphertext []byte) []byte

CBCCiphertext cbc模式下对0进行填充的数据进行原始数据提取

func CBCPlaintext

func CBCPlaintext(plaintext []byte) []byte

CBCPlaintext cbc模式下使用0进行填充

func DefaultIV

func DefaultIV(bt []byte) error

DefaultIV 设置默认的iv

func DefaultNonce

func DefaultNonce(bt []byte)

DefaultNonce 设置GCM模式下nonce的默认值

Types

type MODE

type MODE string

MODE 分组加密模式类型

const (
	//CFB CFB
	CFB MODE = "CFB"
	//CTR CTR
	CTR MODE = "CTR"
	//OFB OFB
	OFB MODE = "OFB"
)

Jump to

Keyboard shortcuts

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