encryption

package
v0.0.0-...-0871eb3 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2021 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAesEncrypt

func GetAesEncrypt(baseString string) (string, error)

GetAesEncrypt to cipher by Aes

func GetBase64Decode

func GetBase64Decode(src []byte) ([]byte, error)

GetBase64Decode is to decode by base64

func GetBase64Encode

func GetBase64Encode(src []byte) []byte

GetBase64Encode is to encode by Base64

Types

type Crypt

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

Crypt is for cipher config data

func GetCrypt

func GetCrypt() *Crypt

GetCrypt is to get crypt instance

func NewCrypt

func NewCrypt(key, iv string) (*Crypt, error)

NewCrypt is to create crypt instance key size should be 16,24,32 iv size should be 16

func NewCryptWithEnv

func NewCryptWithEnv() (*Crypt, error)

NewCryptWithEnv is setup with default settings.

func (*Crypt) Decrypt

func (c *Crypt) Decrypt(src []byte) []byte

Decrypt is to decrypt a slice of bytes, producing a new, freshly allocated slice Source will be padded with null bytes if necessary

func (*Crypt) DecryptBase64

func (c *Crypt) DecryptBase64(base64String string) (string, error)

DecryptBase64 is to decrypt decoded Base64 string

func (*Crypt) DecryptStream

func (c *Crypt) DecryptStream(reader io.Reader, writer io.Writer) error

DecryptStream is to decrypt blocks from reader, write results into writer

func (*Crypt) Encrypt

func (c *Crypt) Encrypt(src []byte) []byte

Encrypt is encrypt a slice of bytes, producing a new, freshly allocated slice Source will be padded with null bytes if necessary

func (*Crypt) EncryptBase64

func (c *Crypt) EncryptBase64(plainText string) string

EncryptBase64 is encrypt and encode by base64 string

func (*Crypt) EncryptStream

func (c *Crypt) EncryptStream(reader io.Reader, writer io.Writer) error

EncryptStream is to encrypt blocks from reader, write results into writer

Jump to

Keyboard shortcuts

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