crypto

package
v1.0.2017 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2023 License: Apache-2.0 Imports: 30 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	AesCFB = TypeMultiple.Generate()
	AesECB = TypeMultiple.Generate()
)
View Source
var TypeMode = NewTypeSet[Mode, string](maxMode)

模式

View Source
var TypeMultiple = NewTypeSet[Multiple, string](maxMultiple)

类型

View Source
var TypePadding = NewTypeSet[Padding, string](maxPadding)

补码

View Source
var UseEncrypt = NewDataSet[Multiple, IEncrypt]()

加密解密

View Source
var UseMode = NewDataSet[Mode, IMode]()

模式

View Source
var UsePadding = NewDataSet[Padding, IPadding]()

补码

Functions

func BlockDecrypt added in v1.0.2001

func BlockDecrypt(block cipher.Block, data []byte, opt IOption) ([]byte, error)

解密

func BlockEncrypt added in v1.0.2001

func BlockEncrypt(block cipher.Block, data []byte, opt IOption) ([]byte, error)

加密

Types

type Config added in v1.0.2001

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

*

  • 包装配置 *
  • @create 2023-3-30
  • @author deatil

func NewConfig added in v1.0.2001

func NewConfig(c Cryptobin) Config

构造函数

func (Config) Config added in v1.0.2001

func (this Config) Config() *tool.Config

额外配置

func (Config) Iv added in v1.0.2001

func (this Config) Iv() []byte

向量

func (Config) Key added in v1.0.2001

func (this Config) Key() []byte

密钥

func (Config) Mode added in v1.0.2001

func (this Config) Mode() Mode

加密模式

func (Config) Multiple added in v1.0.2001

func (this Config) Multiple() Multiple

加密类型

func (Config) Padding added in v1.0.2001

func (this Config) Padding() Padding

填充模式

type Cryptobin

type Cryptobin struct {

	// 错误
	Errors []error
	// contains filtered or unexported fields
}

*

  • 对称加密 *
  • @create 2022-3-19
  • @author deatil

func FromBase64String

func FromBase64String(data string) Cryptobin

Base64

func FromBytes

func FromBytes(data []byte) Cryptobin

字节

func FromHexString

func FromHexString(data string) Cryptobin

Hex

func FromString

func FromString(data string) Cryptobin

字符

func New

func New() Cryptobin

构造函数

func NewCryptobin added in v1.0.1018

func NewCryptobin() Cryptobin

构造函数

func (Cryptobin) Aes

func (this Cryptobin) Aes() Cryptobin

Aes

func (Cryptobin) AesCFB added in v1.0.2001

func (this Cryptobin) AesCFB() Cryptobin

特殊的 AesCFB 组合模式 也可以使用: MultipleBy(AesCFB)

func (Cryptobin) AesECB added in v1.0.2001

func (this Cryptobin) AesECB() Cryptobin

特殊的 AesECB 组合模式 也可以使用: MultipleBy(AesECB)

func (Cryptobin) AppendError added in v1.0.1026

func (this Cryptobin) AppendError(err ...error) Cryptobin

添加错误

func (Cryptobin) Aria added in v1.0.2013

func (this Cryptobin) Aria() Cryptobin

Aria key is 16, 24, or 32 bytes.

func (Cryptobin) Blowfish

func (this Cryptobin) Blowfish(salt ...string) Cryptobin

Blowfish

func (Cryptobin) CBC

func (this Cryptobin) CBC() Cryptobin

密码分组链接模式

func (Cryptobin) CCM added in v1.0.1032

func (this Cryptobin) CCM(nonce string, additional ...string) Cryptobin

CCM ccm nounce size, should be in [7,13]

func (Cryptobin) CFB

func (this Cryptobin) CFB() Cryptobin

密码反馈模式

func (Cryptobin) CFB1 added in v1.0.2006

func (this Cryptobin) CFB1() Cryptobin

密码反馈模式

func (Cryptobin) CFB128 added in v1.0.2006

func (this Cryptobin) CFB128() Cryptobin

密码反馈模式, 标准库 CFB 别名

func (Cryptobin) CFB16 added in v1.0.2006

func (this Cryptobin) CFB16() Cryptobin

密码反馈模式

func (Cryptobin) CFB32 added in v1.0.2006

func (this Cryptobin) CFB32() Cryptobin

密码反馈模式

func (Cryptobin) CFB64 added in v1.0.2006

func (this Cryptobin) CFB64() Cryptobin

密码反馈模式

func (Cryptobin) CFB8 added in v1.0.1021

func (this Cryptobin) CFB8() Cryptobin

密码反馈模式, 8字节

func (Cryptobin) CTR

func (this Cryptobin) CTR() Cryptobin

计算器模式

func (Cryptobin) Camellia added in v1.0.2013

func (this Cryptobin) Camellia() Cryptobin

Camellia The key argument should be 16, 24, or 32 bytes.

func (Cryptobin) Cast5

func (this Cryptobin) Cast5() Cryptobin

Cast5

func (Cryptobin) Chacha20

func (this Cryptobin) Chacha20(nonce string, counter ...uint32) Cryptobin

Chacha20 | Chacha20IETF | XChacha20

func (Cryptobin) Chacha20poly1305

func (this Cryptobin) Chacha20poly1305(nonce string, additional string) Cryptobin

Chacha20poly1305 nonce is 12 bytes

func (Cryptobin) Chacha20poly1305X added in v1.0.1031

func (this Cryptobin) Chacha20poly1305X(nonce string, additional string) Cryptobin

Chacha20poly1305X nonce is 24 bytes

func (Cryptobin) Decrypt

func (this Cryptobin) Decrypt() Cryptobin

解密

func (Cryptobin) Des

func (this Cryptobin) Des() Cryptobin

Des

func (Cryptobin) ECB

func (this Cryptobin) ECB() Cryptobin

电码本模式

func (Cryptobin) Encrypt

func (this Cryptobin) Encrypt() Cryptobin

加密

func (Cryptobin) Error

func (this Cryptobin) Error() error

获取错误

func (Cryptobin) FromBase64String

func (this Cryptobin) FromBase64String(data string) Cryptobin

Base64

func (Cryptobin) FromBytes

func (this Cryptobin) FromBytes(data []byte) Cryptobin

字节

func (Cryptobin) FromHexString

func (this Cryptobin) FromHexString(data string) Cryptobin

Hex

func (Cryptobin) FromString

func (this Cryptobin) FromString(data string) Cryptobin

字符

func (Cryptobin) FuncDecrypt

func (this Cryptobin) FuncDecrypt(f func(Cryptobin) Cryptobin) Cryptobin

方法解密

func (Cryptobin) FuncEncrypt

func (this Cryptobin) FuncEncrypt(f func(Cryptobin) Cryptobin) Cryptobin

方法加密

func (Cryptobin) GCM

func (this Cryptobin) GCM(nonce string, additional ...string) Cryptobin

GCM

func (Cryptobin) GetConfig

func (this Cryptobin) GetConfig() *cryptobin_tool.Config

获取全部配置

func (Cryptobin) GetData

func (this Cryptobin) GetData() []byte

数据

func (Cryptobin) GetErrors added in v1.0.1026

func (this Cryptobin) GetErrors() []error

错误信息

func (Cryptobin) GetIv

func (this Cryptobin) GetIv() []byte

向量

func (Cryptobin) GetKey

func (this Cryptobin) GetKey() []byte

密码

func (Cryptobin) GetMode

func (this Cryptobin) GetMode() Mode

加密方式

func (Cryptobin) GetMultiple

func (this Cryptobin) GetMultiple() Multiple

加密类型

func (Cryptobin) GetOneConfig

func (this Cryptobin) GetOneConfig(key string) any

获取一个配置

func (Cryptobin) GetPadding

func (this Cryptobin) GetPadding() Padding

补码算法

func (Cryptobin) GetParsedData

func (this Cryptobin) GetParsedData() []byte

解析后的数据

func (Cryptobin) ISO10126Padding

func (this Cryptobin) ISO10126Padding() Cryptobin

ISO10126 补码

func (Cryptobin) ISO7816_4Padding

func (this Cryptobin) ISO7816_4Padding() Cryptobin

ISO7816_4 补码

func (Cryptobin) ISO97971Padding added in v1.0.1026

func (this Cryptobin) ISO97971Padding() Cryptobin

ISO97971 补码

func (Cryptobin) Idea added in v1.0.2013

func (this Cryptobin) Idea() Cryptobin

Idea

func (Cryptobin) ModeBy added in v1.0.2001

func (this Cryptobin) ModeBy(mode Mode, cfg ...map[string]any) Cryptobin

使用模式

func (Cryptobin) MultipleBy added in v1.0.2001

func (this Cryptobin) MultipleBy(multiple Multiple, cfg ...map[string]any) Cryptobin

使用类型

func (Cryptobin) NoPadding

func (this Cryptobin) NoPadding() Cryptobin

不补码

func (Cryptobin) NoParse

func (this Cryptobin) NoParse() Cryptobin

不做处理

func (Cryptobin) OFB

func (this Cryptobin) OFB() Cryptobin

输出反馈模式

func (Cryptobin) OFB8 added in v1.0.1021

func (this Cryptobin) OFB8() Cryptobin

输出反馈模式, 8字节

func (Cryptobin) OnError

func (this Cryptobin) OnError(fn ErrorFunc) Cryptobin

引出错误信息

func (Cryptobin) PCBC added in v1.0.2007

func (this Cryptobin) PCBC() Cryptobin

填充密码块链接模式

func (Cryptobin) PKCS1Padding

func (this Cryptobin) PKCS1Padding(bt ...string) Cryptobin

PKCS1 补码

func (Cryptobin) PKCS5Padding

func (this Cryptobin) PKCS5Padding() Cryptobin

PKCS5 补码

func (Cryptobin) PKCS7Padding

func (this Cryptobin) PKCS7Padding() Cryptobin

PKCS7 补码

func (Cryptobin) PaddingBy added in v1.0.2001

func (this Cryptobin) PaddingBy(padding Padding, cfg ...map[string]any) Cryptobin

使用补码算法

func (Cryptobin) PutConfig added in v1.0.2001

func (this Cryptobin) PutConfig(key string, value any) Cryptobin

设置一个配置

func (Cryptobin) RC2 added in v1.0.1032

func (this Cryptobin) RC2() Cryptobin

RC2

func (Cryptobin) RC4

func (this Cryptobin) RC4() Cryptobin

RC4

func (Cryptobin) RC4MD5 added in v1.0.2013

func (this Cryptobin) RC4MD5() Cryptobin

RC4MD5

func (Cryptobin) RC5 added in v1.0.1039

func (this Cryptobin) RC5(wordSize, rounds uint) Cryptobin

RC5

func (Cryptobin) SM4

func (this Cryptobin) SM4() Cryptobin

SM4

func (Cryptobin) Salsa20 added in v1.0.2013

func (this Cryptobin) Salsa20(nonce string) Cryptobin

Salsa20 key is 32 bytes, nonce is 16 bytes.

func (Cryptobin) Seed added in v1.0.2013

func (this Cryptobin) Seed() Cryptobin

Seed The key argument should be 16 bytes.

func (Cryptobin) SetConfig added in v1.0.1046

func (this Cryptobin) SetConfig(data map[string]any) Cryptobin

批量设置配置

func (Cryptobin) SetData added in v1.0.2001

func (this Cryptobin) SetData(data string) Cryptobin

设置数据

func (Cryptobin) SetIv

func (this Cryptobin) SetIv(data string) Cryptobin

向量

func (Cryptobin) SetKey

func (this Cryptobin) SetKey(data string) Cryptobin

密码

func (Cryptobin) SetMode added in v1.0.2001

func (this Cryptobin) SetMode(mode Mode, cfg map[string]any) Cryptobin

设置加密模式带参数

func (Cryptobin) SetMultiple added in v1.0.2001

func (this Cryptobin) SetMultiple(multiple Multiple, cfg map[string]any) Cryptobin

设置加密类型带参数

func (Cryptobin) SetPadding added in v1.0.2001

func (this Cryptobin) SetPadding(padding Padding, cfg map[string]any) Cryptobin

设置补码算法带参数

func (Cryptobin) SetParsedData added in v1.0.2001

func (this Cryptobin) SetParsedData(data string) Cryptobin

设置解析后的数据

func (Cryptobin) String

func (this Cryptobin) String() string

输出原始字符

func (Cryptobin) TBCPadding

func (this Cryptobin) TBCPadding() Cryptobin

TBC 补码

func (Cryptobin) Tea

func (this Cryptobin) Tea(rounds ...int) Cryptobin

Tea

func (Cryptobin) ToBase64String

func (this Cryptobin) ToBase64String() string

输出Base64

func (Cryptobin) ToBytes

func (this Cryptobin) ToBytes() []byte

输出字节

func (Cryptobin) ToHexString

func (this Cryptobin) ToHexString() string

输出Hex

func (Cryptobin) ToString

func (this Cryptobin) ToString() string

输出字符

func (Cryptobin) TripleDes added in v1.0.1047

func (this Cryptobin) TripleDes() Cryptobin

TripleDes

func (Cryptobin) TwoDes added in v1.0.2010

func (this Cryptobin) TwoDes() Cryptobin

TwoDes

func (Cryptobin) Twofish

func (this Cryptobin) Twofish() Cryptobin

Twofish

func (Cryptobin) WithConfig

func (this Cryptobin) WithConfig(config *cryptobin_tool.Config) Cryptobin

设置配置

func (Cryptobin) WithData

func (this Cryptobin) WithData(data []byte) Cryptobin

设置数据

func (Cryptobin) WithErrors added in v1.0.1026

func (this Cryptobin) WithErrors(errs []error) Cryptobin

设置错误

func (Cryptobin) WithIv

func (this Cryptobin) WithIv(iv []byte) Cryptobin

设置向量

func (Cryptobin) WithKey

func (this Cryptobin) WithKey(key []byte) Cryptobin

设置密钥

func (Cryptobin) WithMode

func (this Cryptobin) WithMode(mode Mode) Cryptobin

加密方式

func (Cryptobin) WithMultiple

func (this Cryptobin) WithMultiple(multiple Multiple) Cryptobin

加密类型

func (Cryptobin) WithPadding

func (this Cryptobin) WithPadding(padding Padding) Cryptobin

补码算法

func (Cryptobin) WithParsedData

func (this Cryptobin) WithParsedData(data []byte) Cryptobin

设置解析后的数据

func (Cryptobin) X923Padding

func (this Cryptobin) X923Padding() Cryptobin

X923 补码

func (Cryptobin) Xtea

func (this Cryptobin) Xtea() Cryptobin

Xtea

func (Cryptobin) Xts

func (this Cryptobin) Xts(cipher string, sectorNum uint64) Cryptobin

Xts cipher 可用 [ Aes | Des | TripleDes | Tea | Xtea | Twofish | Blowfish | Cast5 | SM4]

func (Cryptobin) ZeroPadding

func (this Cryptobin) ZeroPadding() Cryptobin

Zero 补码

type DataName added in v1.0.2001

type DataName interface {
	~uint | ~int | ~string
}

type DataSet added in v1.0.2001

type DataSet[N DataName, M any] struct {
	// contains filtered or unexported fields
}

*

  • 数据设置 *
  • @create 2023-3-31
  • @author deatil

func NewDataSet added in v1.0.2001

func NewDataSet[N DataName, M any]() *DataSet[N, M]

构造函数

func (*DataSet[N, M]) Add added in v1.0.2001

func (this *DataSet[N, M]) Add(name N, data func() M) *DataSet[N, M]

设置

func (*DataSet[N, M]) All added in v1.0.2001

func (this *DataSet[N, M]) All() map[N]func() M

func (*DataSet[N, M]) Clean added in v1.0.2001

func (this *DataSet[N, M]) Clean()

func (*DataSet[N, M]) Get added in v1.0.2001

func (this *DataSet[N, M]) Get(name N) func() M

func (*DataSet[N, M]) Has added in v1.0.2001

func (this *DataSet[N, M]) Has(name N) bool

func (*DataSet[N, M]) Len added in v1.0.2001

func (this *DataSet[N, M]) Len() int

func (*DataSet[N, M]) Names added in v1.0.2001

func (this *DataSet[N, M]) Names() []N

func (*DataSet[N, M]) Remove added in v1.0.2001

func (this *DataSet[N, M]) Remove(name N) *DataSet[N, M]

删除

type EncryptAes added in v1.0.2001

type EncryptAes struct{}

NewCipher creates and returns a new cipher.Block. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func (EncryptAes) Decrypt added in v1.0.2001

func (this EncryptAes) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptAes) Encrypt added in v1.0.2001

func (this EncryptAes) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptAesCFB added in v1.0.2001

type EncryptAesCFB struct{}

func (EncryptAesCFB) Decrypt added in v1.0.2001

func (this EncryptAesCFB) Decrypt(encrypted []byte, opt IOption) ([]byte, error)

解密

func (EncryptAesCFB) Encrypt added in v1.0.2001

func (this EncryptAesCFB) Encrypt(origData []byte, opt IOption) ([]byte, error)

加密

type EncryptAesECB added in v1.0.2001

type EncryptAesECB struct{}

func (EncryptAesECB) Decrypt added in v1.0.2001

func (this EncryptAesECB) Decrypt(encrypted []byte, opt IOption) ([]byte, error)

func (EncryptAesECB) Encrypt added in v1.0.2001

func (this EncryptAesECB) Encrypt(origData []byte, opt IOption) ([]byte, error)

type EncryptAria added in v1.0.2013

type EncryptAria struct{}

Aria key is 16, 24, or 32 bytes.

func (EncryptAria) Decrypt added in v1.0.2013

func (this EncryptAria) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptAria) Encrypt added in v1.0.2013

func (this EncryptAria) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptBlowfish added in v1.0.2001

type EncryptBlowfish struct{}

func (EncryptBlowfish) Decrypt added in v1.0.2001

func (this EncryptBlowfish) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptBlowfish) Encrypt added in v1.0.2001

func (this EncryptBlowfish) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptCamellia added in v1.0.2013

type EncryptCamellia struct{}

Camellia key is 16, 24, or 32 bytes.

func (EncryptCamellia) Decrypt added in v1.0.2013

func (this EncryptCamellia) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptCamellia) Encrypt added in v1.0.2013

func (this EncryptCamellia) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptCast5 added in v1.0.2001

type EncryptCast5 struct{}

func (EncryptCast5) Decrypt added in v1.0.2001

func (this EncryptCast5) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptCast5) Encrypt added in v1.0.2001

func (this EncryptCast5) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptChacha20 added in v1.0.2001

type EncryptChacha20 struct{}

32 bytes key and a 12 or 24 bytes nonce

func (EncryptChacha20) Decrypt added in v1.0.2001

func (this EncryptChacha20) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptChacha20) Encrypt added in v1.0.2001

func (this EncryptChacha20) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptChacha20poly1305 added in v1.0.2001

type EncryptChacha20poly1305 struct{}

32 bytes key

func (EncryptChacha20poly1305) Decrypt added in v1.0.2001

func (this EncryptChacha20poly1305) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptChacha20poly1305) Encrypt added in v1.0.2001

func (this EncryptChacha20poly1305) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptChacha20poly1305X added in v1.0.2001

type EncryptChacha20poly1305X struct{}

32 bytes key

func (EncryptChacha20poly1305X) Decrypt added in v1.0.2001

func (this EncryptChacha20poly1305X) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptChacha20poly1305X) Encrypt added in v1.0.2001

func (this EncryptChacha20poly1305X) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptDes added in v1.0.2001

type EncryptDes struct{}

func (EncryptDes) Decrypt added in v1.0.2001

func (this EncryptDes) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptDes) Encrypt added in v1.0.2001

func (this EncryptDes) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptIdea added in v1.0.2013

type EncryptIdea struct{}

func (EncryptIdea) Decrypt added in v1.0.2013

func (this EncryptIdea) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptIdea) Encrypt added in v1.0.2013

func (this EncryptIdea) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptRC2 added in v1.0.2001

type EncryptRC2 struct{}

func (EncryptRC2) Decrypt added in v1.0.2001

func (this EncryptRC2) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptRC2) Encrypt added in v1.0.2001

func (this EncryptRC2) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptRC4 added in v1.0.2001

type EncryptRC4 struct{}

RC4 key, at least 1 byte and at most 256 bytes.

func (EncryptRC4) Decrypt added in v1.0.2001

func (this EncryptRC4) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptRC4) Encrypt added in v1.0.2001

func (this EncryptRC4) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptRC4MD5 added in v1.0.2013

type EncryptRC4MD5 struct{}

RC4 key, at least 1 byte and at most 256 bytes.

func (EncryptRC4MD5) Decrypt added in v1.0.2013

func (this EncryptRC4MD5) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptRC4MD5) Encrypt added in v1.0.2013

func (this EncryptRC4MD5) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptRC5 added in v1.0.2001

type EncryptRC5 struct{}

func (EncryptRC5) Decrypt added in v1.0.2001

func (this EncryptRC5) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptRC5) Encrypt added in v1.0.2001

func (this EncryptRC5) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptSM4 added in v1.0.2001

type EncryptSM4 struct{}

func (EncryptSM4) Decrypt added in v1.0.2001

func (this EncryptSM4) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptSM4) Encrypt added in v1.0.2001

func (this EncryptSM4) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptSalsa20 added in v1.0.2013

type EncryptSalsa20 struct{}

Salsa20 key is 32 bytes. nonce is 16 bytes.

func (EncryptSalsa20) Decrypt added in v1.0.2013

func (this EncryptSalsa20) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptSalsa20) Encrypt added in v1.0.2013

func (this EncryptSalsa20) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptSeed added in v1.0.2013

type EncryptSeed struct{}

Seed key is 16 bytes.

func (EncryptSeed) Decrypt added in v1.0.2013

func (this EncryptSeed) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptSeed) Encrypt added in v1.0.2013

func (this EncryptSeed) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptTea added in v1.0.2001

type EncryptTea struct{}

func (EncryptTea) Decrypt added in v1.0.2001

func (this EncryptTea) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptTea) Encrypt added in v1.0.2001

func (this EncryptTea) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptTripleDes added in v1.0.2001

type EncryptTripleDes struct{}

func (EncryptTripleDes) Decrypt added in v1.0.2001

func (this EncryptTripleDes) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptTripleDes) Encrypt added in v1.0.2001

func (this EncryptTripleDes) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptTwoDes added in v1.0.2010

type EncryptTwoDes struct{}

func (EncryptTwoDes) Decrypt added in v1.0.2010

func (this EncryptTwoDes) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptTwoDes) Encrypt added in v1.0.2010

func (this EncryptTwoDes) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptTwofish added in v1.0.2001

type EncryptTwofish struct{}

The key argument should be the Twofish key, 16, 24 or 32 bytes.

func (EncryptTwofish) Decrypt added in v1.0.2001

func (this EncryptTwofish) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptTwofish) Encrypt added in v1.0.2001

func (this EncryptTwofish) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptXtea added in v1.0.2001

type EncryptXtea struct{}

func (EncryptXtea) Decrypt added in v1.0.2001

func (this EncryptXtea) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptXtea) Encrypt added in v1.0.2001

func (this EncryptXtea) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type EncryptXts added in v1.0.2001

type EncryptXts struct{}

Sectors must be a multiple of 16 bytes and less than 2²⁴ bytes.

func (EncryptXts) Decrypt added in v1.0.2001

func (this EncryptXts) Decrypt(data []byte, opt IOption) ([]byte, error)

解密

func (EncryptXts) Encrypt added in v1.0.2001

func (this EncryptXts) Encrypt(data []byte, opt IOption) ([]byte, error)

加密

type ErrorFunc

type ErrorFunc = func([]error)

错误方法

type IEncrypt added in v1.0.2001

type IEncrypt interface {
	// 加密
	Encrypt([]byte, IOption) ([]byte, error)

	// 解密
	Decrypt([]byte, IOption) ([]byte, error)
}

加密接口

type IMode added in v1.0.2001

type IMode interface {
	// 加密
	Encrypt([]byte, cipher.Block, IOption) ([]byte, error)

	// 解密
	Decrypt([]byte, cipher.Block, IOption) ([]byte, error)
}

模式接口

type IOption added in v1.0.2001

type IOption interface {
	// 密钥
	Key() []byte

	// 向量
	Iv() []byte

	// 加密类型
	Multiple() Multiple

	// 加密模式
	Mode() Mode

	// 填充模式
	Padding() Padding

	// 额外配置
	Config() *tool.Config
}

配置接口

type IPadding added in v1.0.2001

type IPadding interface {
	// 补码
	Padding([]byte, int, IOption) []byte

	// 解密
	UnPadding([]byte, IOption) []byte
}

补码接口

type ISO10126Paddinger added in v1.0.2001

type ISO10126Paddinger struct{}

func (ISO10126Paddinger) Padding added in v1.0.2001

func (this ISO10126Paddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (ISO10126Paddinger) UnPadding added in v1.0.2006

func (this ISO10126Paddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type ISO7816_4Paddinger added in v1.0.2001

type ISO7816_4Paddinger struct{}

func (ISO7816_4Paddinger) Padding added in v1.0.2001

func (this ISO7816_4Paddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (ISO7816_4Paddinger) UnPadding added in v1.0.2006

func (this ISO7816_4Paddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type ISO97971Paddinger added in v1.0.2001

type ISO97971Paddinger struct{}

func (ISO97971Paddinger) Padding added in v1.0.2001

func (this ISO97971Paddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (ISO97971Paddinger) UnPadding added in v1.0.2006

func (this ISO97971Paddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type Mode added in v1.0.1045

type Mode uint

加密模式

const (
	ECB Mode = 1 + iota
	CBC
	PCBC
	CFB
	CFB1
	CFB8
	CFB16
	CFB32
	CFB64
	CFB128
	OFB
	OFB8
	CTR
	GCM
	CCM
)

func (Mode) String added in v1.0.1045

func (this Mode) String() string

type ModeCBC added in v1.0.2001

type ModeCBC struct{}

func (ModeCBC) Decrypt added in v1.0.2001

func (this ModeCBC) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCBC) Encrypt added in v1.0.2001

func (this ModeCBC) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCCM added in v1.0.2001

type ModeCCM struct{}

func (ModeCCM) Decrypt added in v1.0.2001

func (this ModeCCM) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCCM) Encrypt added in v1.0.2001

func (this ModeCCM) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCFB added in v1.0.2001

type ModeCFB struct{}

func (ModeCFB) Decrypt added in v1.0.2001

func (this ModeCFB) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCFB) Encrypt added in v1.0.2001

func (this ModeCFB) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCFB1 added in v1.0.2006

type ModeCFB1 struct{}

func (ModeCFB1) Decrypt added in v1.0.2006

func (this ModeCFB1) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCFB1) Encrypt added in v1.0.2006

func (this ModeCFB1) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCFB16 added in v1.0.2006

type ModeCFB16 struct{}

func (ModeCFB16) Decrypt added in v1.0.2006

func (this ModeCFB16) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCFB16) Encrypt added in v1.0.2006

func (this ModeCFB16) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCFB32 added in v1.0.2006

type ModeCFB32 struct{}

func (ModeCFB32) Decrypt added in v1.0.2006

func (this ModeCFB32) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCFB32) Encrypt added in v1.0.2006

func (this ModeCFB32) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCFB64 added in v1.0.2006

type ModeCFB64 struct{}

func (ModeCFB64) Decrypt added in v1.0.2006

func (this ModeCFB64) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCFB64) Encrypt added in v1.0.2006

func (this ModeCFB64) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCFB8 added in v1.0.2001

type ModeCFB8 struct{}

func (ModeCFB8) Decrypt added in v1.0.2001

func (this ModeCFB8) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCFB8) Encrypt added in v1.0.2001

func (this ModeCFB8) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeCTR added in v1.0.2001

type ModeCTR struct{}

func (ModeCTR) Decrypt added in v1.0.2001

func (this ModeCTR) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeCTR) Encrypt added in v1.0.2001

func (this ModeCTR) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeECB added in v1.0.2001

type ModeECB struct{}

func (ModeECB) Decrypt added in v1.0.2001

func (this ModeECB) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeECB) Encrypt added in v1.0.2001

func (this ModeECB) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeGCM added in v1.0.2001

type ModeGCM struct{}

func (ModeGCM) Decrypt added in v1.0.2001

func (this ModeGCM) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeGCM) Encrypt added in v1.0.2001

func (this ModeGCM) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeOFB added in v1.0.2001

type ModeOFB struct{}

func (ModeOFB) Decrypt added in v1.0.2001

func (this ModeOFB) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeOFB) Encrypt added in v1.0.2001

func (this ModeOFB) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModeOFB8 added in v1.0.2001

type ModeOFB8 struct{}

func (ModeOFB8) Decrypt added in v1.0.2001

func (this ModeOFB8) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModeOFB8) Encrypt added in v1.0.2001

func (this ModeOFB8) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type ModePCBC added in v1.0.2007

type ModePCBC struct{}

func (ModePCBC) Decrypt added in v1.0.2007

func (this ModePCBC) Decrypt(data []byte, block cipher.Block, opt IOption) ([]byte, error)

解密

func (ModePCBC) Encrypt added in v1.0.2007

func (this ModePCBC) Encrypt(plain []byte, block cipher.Block, opt IOption) ([]byte, error)

加密

type Multiple added in v1.0.1045

type Multiple uint

加密类型

const (
	Aes Multiple = 1 + iota
	Des
	TwoDes
	TripleDes
	Twofish
	Blowfish
	Tea
	Xtea
	Cast5
	RC2
	RC4
	RC4MD5
	RC5
	Idea
	SM4
	Chacha20
	Chacha20poly1305
	Chacha20poly1305X
	Xts
	Salsa20
	Seed
	Aria
	Camellia
)

func (Multiple) String added in v1.0.1045

func (this Multiple) String() string

type NoPaddinger added in v1.0.2001

type NoPaddinger struct{}

func (NoPaddinger) Padding added in v1.0.2001

func (this NoPaddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (NoPaddinger) UnPadding added in v1.0.2006

func (this NoPaddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type PKCS1Paddinger added in v1.0.2001

type PKCS1Paddinger struct{}

func (PKCS1Paddinger) Padding added in v1.0.2001

func (this PKCS1Paddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (PKCS1Paddinger) UnPadding added in v1.0.2006

func (this PKCS1Paddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type PKCS5Paddinger added in v1.0.2001

type PKCS5Paddinger struct{}

func (PKCS5Paddinger) Padding added in v1.0.2001

func (this PKCS5Paddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (PKCS5Paddinger) UnPadding added in v1.0.2006

func (this PKCS5Paddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type PKCS7Paddinger added in v1.0.2001

type PKCS7Paddinger struct{}

func (PKCS7Paddinger) Padding added in v1.0.2001

func (this PKCS7Paddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (PKCS7Paddinger) UnPadding added in v1.0.2006

func (this PKCS7Paddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type Padding added in v1.0.1045

type Padding uint

补码类型

const (
	NoPadding Padding = 1 + iota
	ZeroPadding
	PKCS5Padding
	PKCS7Padding
	X923Padding
	ISO10126Padding
	ISO7816_4Padding
	ISO97971Padding
	TBCPadding
	PKCS1Padding
)

func (Padding) String added in v1.0.1045

func (this Padding) String() string

type TBCPaddinger added in v1.0.2001

type TBCPaddinger struct{}

func (TBCPaddinger) Padding added in v1.0.2001

func (this TBCPaddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (TBCPaddinger) UnPadding added in v1.0.2006

func (this TBCPaddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type TypeName added in v1.0.2001

type TypeName interface {
	~uint | ~int
}

名称类型

type TypeSet added in v1.0.2001

type TypeSet[N TypeName, D any] struct {
	// contains filtered or unexported fields
}

类型数据

func NewTypeSet added in v1.0.2001

func NewTypeSet[N TypeName, D any](max N) *TypeSet[N, D]

构造函数

func (*TypeSet[N, D]) Generate added in v1.0.2001

func (this *TypeSet[N, D]) Generate() N

生成新序列

func (*TypeSet[N, D]) Names added in v1.0.2001

func (this *TypeSet[N, D]) Names() *DataSet[N, D]

设置

type X923Paddinger added in v1.0.2001

type X923Paddinger struct{}

func (X923Paddinger) Padding added in v1.0.2001

func (this X923Paddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (X923Paddinger) UnPadding added in v1.0.2006

func (this X923Paddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

type ZeroPaddinger added in v1.0.2001

type ZeroPaddinger struct{}

func (ZeroPaddinger) Padding added in v1.0.2001

func (this ZeroPaddinger) Padding(plainText []byte, blockSize int, opt IOption) []byte

Padding 补码模式

func (ZeroPaddinger) UnPadding added in v1.0.2006

func (this ZeroPaddinger) UnPadding(cipherText []byte, opt IOption) []byte

UnPadding 补码模式

Jump to

Keyboard shortcuts

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