encrypt

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2024 License: Apache-2.0 Imports: 10 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AESHandler

type AESHandler struct {
	CipherHandler
}

AESHandler AES CBC 加密模式

func NewAES

func NewAES() *AESHandler

NewAES 实例AES加密

func (*AESHandler) Cipher

func (h *AESHandler) Cipher(handler CipherHandler) *AESHandler

Cipher AES密钥

func (*AESHandler) Decrypt

func (h *AESHandler) Decrypt(ciphertext []byte) (plaintext []byte, err error)

Decrypt 使用AES-CBC解密数据,根据密钥长度选择AES-128, AES-192, 或 AES-256

func (*AESHandler) DecryptString

func (h *AESHandler) DecryptString(rawCipher string) ([]byte, error)

DecryptString 解密原始密文并逆解析转义密文

func (*AESHandler) Encrypt

func (h *AESHandler) Encrypt(plaintext []byte) (ciphertext []byte, err error)

Encrypt 使用AES-CBC加密数据,根据密钥长度选择AES-128, AES-192, 或 AES-256

func (*AESHandler) EncryptString

func (h *AESHandler) EncryptString(plaintext []byte) (string, error)

EncryptString 使用AES-CBC加密数据,根据密钥长度选择AES-128, AES-192, 或 AES-256, 转换为十六进制或base64

func (*AESHandler) GetIv

func (h *AESHandler) GetIv() []byte

GetIv 获取初始化IV向量

func (*AESHandler) MustEncryptString

func (h *AESHandler) MustEncryptString(plaintext []byte) string

MustEncryptString 必须加密字符串 使用AES-CBC加密数据,根据密钥长度选择AES-128, AES-192, 或 AES-256, 转换为十六进制或base64

func (*AESHandler) PKCS7Padding

func (h *AESHandler) PKCS7Padding(src []byte, blockSize int) ([]byte, error)

PKCS7Padding 实现了PKCS#7的填充方式

func (*AESHandler) PKCS7UnPadding

func (h *AESHandler) PKCS7UnPadding(src []byte) ([]byte, error)

PKCS7UnPadding 实现了PKCS#7的去填充方式

type CipherHandler

type CipherHandler struct {
	Secret string
	Iv     string
	Output bool // false默认十六进制,true base64
}

CipherHandler AES密钥

type Md5

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

func NewM

func NewM(b ...byte) *Md5

NewM 实例Md5加密

func (Md5) Encrypt

func (m Md5) Encrypt(data interface{}) (string, error)

Encrypt 使用Md5加密

func (Md5) EncryptBytes

func (m Md5) EncryptBytes() (string, error)

EncryptBytes 使用Md5加密

func (Md5) EncryptString

func (m Md5) EncryptString(s string) (string, error)

EncryptString 使用Md5加密

func (Md5) MustEncrypt

func (m Md5) MustEncrypt(data interface{}) string

MustEncrypt 使用Md5加密

func (Md5) MustEncryptString

func (m Md5) MustEncryptString(s string) string

MustEncryptString 使用Md5加密

Jump to

Keyboard shortcuts

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