wcipher

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package wcipher is a package to encrypt and decrypt data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewECBDecrypt

func NewECBDecrypt(block cipher.Block) cipher.BlockMode

NewECBDecrypt ecb decrypt

func NewECBEncrypt

func NewECBEncrypt(block cipher.Block) cipher.BlockMode

NewECBEncrypt ecb encrypt

Types

type Cipher

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

Cipher provides a unified interface to encrypt/decrypt data.

func NewAES

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

NewAES Create default AES cipher, use ECB working mode, pkcs57 padding, algorithm secret key length 128 192 256 bits, use secret key as initial vector.

func NewAESWith

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

NewAESWith According to the specified working mode, create AES cipher, the length of the algorithm secret key is 128 192 256 bits, and the secret key is used as the initial vector.

func NewBlockCipher

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

NewBlockCipher new block encryption

func NewDES

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

NewDES Create default DES cipher, use ECB working mode, pkcs57 padding, algorithm secret key length 64 bits, use secret key as initial vector.

func NewDESWith

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

NewDESWith According to the specified working mode, create DES cipher, the length of the algorithm secret key is 64 bits, and use the secret key as the initial vector.

func NewStreamCipher

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

NewStreamCipher new stream encryption

type CipherMode

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

CipherMode provides a uniform interface to set the filling method for different operating modes.

func NewCBCMode

func NewCBCMode() CipherMode

NewCBCMode new cbc mode

func NewCFBMode

func NewCFBMode() CipherMode

NewCFBMode new cfb mode

func NewCTRMode

func NewCTRMode() CipherMode

NewCTRMode new ctr mode

func NewECBMode

func NewECBMode() CipherMode

NewECBMode new ecb mode

func NewOFBMode

func NewOFBMode() CipherMode

NewOFBMode new ofb mode

type Padding

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

Padding provides a unified interface to populate/restore data for various population methods.

func NewPKCS57Padding

func NewPKCS57Padding() Padding

NewPKCS57Padding new pkcs57 padding

Jump to

Keyboard shortcuts

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