cipher

package
v0.0.0-...-f84f93e Latest Latest
Warning

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

Go to latest
Published: May 30, 2018 License: Apache-2.0, Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewECBDecrypter

func NewECBDecrypter(block Block) BlockMode

func NewECBEncrypter

func NewECBEncrypter(block Block) BlockMode

Types

type Cipher

type Cipher interface {
	/*
		介绍:加密数据
		作者:Alex
	        版本:release1.1
	*/
	Encrypt(src []byte) []byte
	/*
		介绍:解密数据
		作者:Alex
	        版本:release1.1
	*/
	Decrypt(src []byte) []byte
}

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

作者:Alex 版本:release-1.1

func NewBlockCipher

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

介绍:新建块加密 作者:Alex 版本:release1.1

func NewStreamCipher

func NewStreamCipher(encrypt Stream, decrypt Stream) Cipher

介绍:新建流加密 作者:Alex 版本:release1.1

type CipherMode

type CipherMode interface {
	/*
		设置填充方式,仅块模式需要填充。

		作者:Alex
		版本:release-1.1
	*/
	SetPadding(padding Padding) CipherMode

	/*
		创建Cipher

		作者:Alex
		版本:release-1.1
	*/
	Cipher(block Block, iv []byte) Cipher
}

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

对于流模式,SetPadding是个空方法,不起任何作用。

作者:Alex 版本:release-1.1

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 {
	/*
		介绍:根据块大小填充待加密数据
	        作者:Alex
	        版本:release-1.1
	*/
	Padding(src []byte, blockSize int) []byte
	/*
		介绍:从解密后的数据中取出填充的数据,还原原文
	        作者:Alex
	        版本:release-1.1
	*/
	UnPadding(src []byte) []byte
}

介绍:Padding接口为各种填充方式提供了统一的接口来填充/还原数据。 作者:Alex 版本:release-1.1

func NewPKCS57Padding

func NewPKCS57Padding() Padding

介绍:创建PKCS5/7填充模式 作者:Alex 版本:release-1.1

Jump to

Keyboard shortcuts

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