utilEnc

package
v0.0.0-...-f25d982 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2024 License: MIT Imports: 17 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashSha256

func HashSha256(src string) string

func Md5

func Md5(str string) string

func PKCS7Padding

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

func PKCS7UnPadding

func PKCS7UnPadding(data []byte) (b []byte, err error)

func PasswordHash

func PasswordHash(password string) (string, error)

func PasswordVerify

func PasswordVerify(password, hash string) bool

func RsaCreateKeys

func RsaCreateKeys(keyLength int) (privateKey *rsa.PrivateKey, publicKey *rsa.PublicKey, err error)

func RsaCreateKeysPem

func RsaCreateKeysPem(keyLength int) (privateKeyPem []byte, publicKeyPem []byte, err error)

Types

type AesEncryptor

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

func NewAesEncryptor

func NewAesEncryptor(secret string) (aesEncryptor *AesEncryptor)

func (*AesEncryptor) Decrypt

func (ae *AesEncryptor) Decrypt(data string, v interface{}) (err error)

func (*AesEncryptor) DecryptByte

func (ae *AesEncryptor) DecryptByte(enData []byte, iv []byte) (deData []byte, err error)

func (*AesEncryptor) DecryptString

func (ae *AesEncryptor) DecryptString(data string) (string, error)

func (*AesEncryptor) Encrypt

func (ae *AesEncryptor) Encrypt(data interface{}) (string, error)

func (*AesEncryptor) EncryptByte

func (ae *AesEncryptor) EncryptByte(rawData []byte, iv []byte) (enData []byte, err error)

aes加密,填充秘钥key的16位,24,32分别对应AES-128, AES-192, or AES-256.

func (*AesEncryptor) EncryptString

func (ae *AesEncryptor) EncryptString(data string) (enStr string, err error)

func (*AesEncryptor) GetBlockSize

func (ae *AesEncryptor) GetBlockSize() (size int, err error)

func (*AesEncryptor) GetCipherBlock

func (ae *AesEncryptor) GetCipherBlock() (block cipher.Block, err error)

func (*AesEncryptor) GetSecret

func (ae *AesEncryptor) GetSecret() string

func (*AesEncryptor) RandIv

func (ae *AesEncryptor) RandIv() (iv []byte, err error)

func (*AesEncryptor) SetSecret

func (ae *AesEncryptor) SetSecret(secret string) *AesEncryptor

type RsaEncryptor

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

func NewRsaEncryptor

func NewRsaEncryptor() (encryptor *RsaEncryptor)

func (*RsaEncryptor) RsaBase64DecodeAndPrivateKeyDecrypt

func (r *RsaEncryptor) RsaBase64DecodeAndPrivateKeyDecrypt(cipherText string) (data []byte, err error)

func (*RsaEncryptor) RsaBase64DecodeAndPublicKeyVerifySign

func (r *RsaEncryptor) RsaBase64DecodeAndPublicKeyVerifySign(data []byte, sign string) (err error)

func (*RsaEncryptor) RsaPrivateKeyDecrypt

func (r *RsaEncryptor) RsaPrivateKeyDecrypt(cipher []byte) (data []byte, err error)

func (*RsaEncryptor) RsaPrivateKeySign

func (r *RsaEncryptor) RsaPrivateKeySign(data []byte) (sign []byte, err error)

func (*RsaEncryptor) RsaPrivateKeySignAndBase64

func (r *RsaEncryptor) RsaPrivateKeySignAndBase64(data []byte) (sign string, err error)

func (*RsaEncryptor) RsaPublicKeyEncrypt

func (r *RsaEncryptor) RsaPublicKeyEncrypt(src []byte) (data []byte, err error)

func (*RsaEncryptor) RsaPublicKeyEncryptAndBase64

func (r *RsaEncryptor) RsaPublicKeyEncryptAndBase64(src []byte) (data string, err error)

func (*RsaEncryptor) RsaPublicKeyVerifySign

func (r *RsaEncryptor) RsaPublicKeyVerifySign(data []byte, sign []byte) (err error)

func (*RsaEncryptor) SetPrivateKey

func (r *RsaEncryptor) SetPrivateKey(privateKey []byte) (key *rsa.PrivateKey, err error)

func (*RsaEncryptor) SetPublicKey

func (r *RsaEncryptor) SetPublicKey(publicKey []byte) (key *rsa.PublicKey, err error)

Jump to

Keyboard shortcuts

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