comCipher

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

nolint

nolint

nolint

nolint

nolint

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewECBDecrypter

func NewECBDecrypter(block cipher.Block) cipher.BlockMode

NewECBDecrypter 实例化

func NewECBEncrypter

func NewECBEncrypter(block cipher.Block) cipher.BlockMode

NewECBEncrypter 实例化

Types

type Cipher

type Cipher interface {
	Encrypt(src []byte) []byte
	Decrypt(src []byte) []byte
}

Cipher 提供了统一的接口对数据进行加密/解密操作.

func NewAES

func NewAES(key []byte) (Cipher, error)

NewAES 创建默认的AES Cipher,使用ECB工作模式、pkcs57填充,算法秘钥长度128 192 256 位 , 使用秘钥作为初始向量

func NewAESWith

func NewAESWith(key []byte, mode CipherMode) (Cipher, error)

NewAESWith 根据指定的工作模式,创建AESCipher,算法秘钥长度128 192 256 位 , 使用秘钥作为初始向量

func NewBlockCipher

func NewBlockCipher(padding Padding, encrypt, decrypt cipher.BlockMode) Cipher

NewBlockCipher 新建块加密

func NewDES

func NewDES(key []byte) (Cipher, error)

NewDES 创建默认DESCipher,使用ECB工作模式、pkcs57填充,算法秘钥长度64位 , 使用秘钥作为初始向量

func NewDESWith

func NewDESWith(key []byte, mode CipherMode) (Cipher, error)

NewDESWith 根据指定的工作模式,创建DESCipher,算法秘钥长度64位,使用秘钥作为初始向量

func NewStreamCipher

func NewStreamCipher(encrypt cipher.Stream, decrypt cipher.Stream) Cipher

NewStreamCipher 新建流加密

type CipherMode

type CipherMode interface {
	SetPadding(padding Padding) CipherMode
	Cipher(block cipher.Block, iv []byte) Cipher
}

CipherMode 为不同的工作模式提供了统一的接口来设置填充方式,创建Cipher。

func NewCBCMode

func NewCBCMode() CipherMode

func NewCFBMode

func NewCFBMode() CipherMode

func NewCTRMode

func NewCTRMode() CipherMode

func NewECBMode

func NewECBMode() CipherMode

func NewOFBMode

func NewOFBMode() CipherMode

type Padding

type Padding interface {
	Padding(src []byte, blockSize int) []byte
	UnPadding(src []byte) []byte
}

Padding 为各种填充方式提供了统一的接口来填充/还原数据。

func NewPKCS57Padding

func NewPKCS57Padding() Padding

Jump to

Keyboard shortcuts

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