crypto

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CS7Padding

func CS7Padding(ciphertext []byte, blockSize int) []byte

CS7Padding 补码 AES加密数据块分组长度必须为128bit(byte[16]),密钥长度可以是128bit(byte[16])、192bit(byte[24])、256bit(byte[32])中的任意一个。

func CS7UnPadding

func CS7UnPadding(origData []byte) ([]byte, error)

CS7UnPadding 去码

func ZeroPadding

func ZeroPadding(ciphertext []byte, blockSize int) ([]byte, error)

ZeroPadding ...

func ZeroUnPadding

func ZeroUnPadding(origData []byte) ([]byte, error)

ZeroUnPadding ...

Types

type EncodingWay

type EncodingWay uint

type Encrypt

type Encrypt struct {
	// contains filtered or unexported fields
}

func NewEncrypt

func NewEncrypt(opts ...NewEncryptOption) *Encrypt

NewEncrypt ...

func (Encrypt) Decrypt

func (e Encrypt) Decrypt(encrypted string, key string) (string, error)

Decrypt ...

func (Encrypt) EnCodding

func (e Encrypt) EnCodding(encrypted []byte) string

EnCodding ...

func (Encrypt) Encrypt

func (e Encrypt) Encrypt(orig string, key string) (string, error)

Encrypt ...

func (Encrypt) GetCipherBlock

func (e Encrypt) GetCipherBlock(encrypted []byte) (cipher.Block, error)

GetCipherBlock ...

func (Encrypt) Padding

func (e Encrypt) Padding(ciphertext []byte, blockSize int) ([]byte, error)

Padding ...

func (*Encrypt) UnEnCodding

func (e *Encrypt) UnEnCodding(encrypted string) ([]byte, error)

UnEnCodding ...

func (Encrypt) UnPadding

func (e Encrypt) UnPadding(origData []byte) ([]byte, error)

UnPadding ...

type EncryptMode

type EncryptMode uint
const (
	AESDESModeECB EncryptMode = iota + 1
)

type EncryptWay

type EncryptWay uint
const (
	EncryptWayAES EncryptWay = iota + 1
	EncryptWatDES
)

type NewEncryptOption

type NewEncryptOption func(encrypt *Encrypt)

NewEncryptOption ...

func WithAesEncryptMode

func WithAesEncryptMode(mode EncryptMode) NewEncryptOption

WithAesEncryptMode ...

func WithAesEncryptModePaddingWay

func WithAesEncryptModePaddingWay(way PaddingWay) NewEncryptOption

WithAesEncryptModePaddingWay ...

func WithEncodingWay

func WithEncodingWay(way EncodingWay) NewEncryptOption

WithEncodingWay ...

func WithEncryptWay

func WithEncryptWay(way EncryptWay) NewEncryptOption

WithEncryptWay ...

type PaddingWay

type PaddingWay uint
const (
	PaddingWayCS7 PaddingWay = iota + 1
	PaddingWayCS5
	PaddingWayZero
)

Jump to

Keyboard shortcuts

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