wcipher

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package wcipher 用于加密和解密数据的包

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewECBDecrypt

func NewECBDecrypt(block cipher.Block) cipher.BlockMode

NewECBDecrypt ECB解密

func NewECBEncrypt

func NewECBEncrypt(block cipher.Block) cipher.BlockMode

NewECBEncrypt ECB加密

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密码器,使用ECB工作模式,pkcs57填充, 算法密钥长度128 192 256位,使用密钥作为初始向量。

func NewAESWith

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

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

func NewBlockCipher

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

NewBlockCipher 创建新的块加密

func NewDES

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

NewDES 创建默认DES密码器,使用ECB工作模式,pkcs57填充, 算法密钥长度64位,使用密钥作为初始向量。

func NewDESWith

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

NewDESWith 根据指定的工作模式创建DES密码器, 算法密钥长度为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 为不同操作模式提供统一的填充方法设置接口

func NewCBCMode

func NewCBCMode() CipherMode

NewCBCMode 创建新的CBC模式

func NewCFBMode

func NewCFBMode() CipherMode

NewCFBMode 创建新的CFB模式

func NewCTRMode

func NewCTRMode() CipherMode

NewCTRMode 创建新的CTR模式

func NewECBMode

func NewECBMode() CipherMode

NewECBMode 创建新的ECB模式

func NewOFBMode

func NewOFBMode() CipherMode

NewOFBMode 创建新的OFB模式

type Padding

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

Padding 为各种填充方法提供统一的数据填充/恢复接口

func NewPKCS57Padding

func NewPKCS57Padding() Padding

NewPKCS57Padding 创建新的PKCS57填充

Jump to

Keyboard shortcuts

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