encrypt

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2020 License: BSD-3-Clause Imports: 5 Imported by: 1

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AesEncrypt

type AesEncrypt struct {
	Key string
}

AesEncrypt 加密的定义结构

func (*AesEncrypt) Decrypt

func (a *AesEncrypt) Decrypt(src []byte) (strDesc []byte, err error)

Decrypt 解密字符串

Example
aesEnc := AesEncrypt{"1234334"}
arrEncrypt, err := aesEnc.Encrypt([]byte("abcdef"))
if err != nil {
	log.Println(arrEncrypt)
	return
}
aesDec := AesEncrypt{"1234335"}
strMsg, err := aesDec.Decrypt(arrEncrypt)
if err != nil {
	fmt.Printf("error password")
	return
}
fmt.Println(string(strMsg))
Output:

error password

func (*AesEncrypt) Encrypt

func (a *AesEncrypt) Encrypt(strMesg []byte) ([]byte, error)

Encrypt 加密字符串

Example
aesEnc := AesEncrypt{"1234334"}
arrEncrypt, err := aesEnc.Encrypt([]byte("abcdef"))
if err != nil {
	log.Println(arrEncrypt)
	return
}
strMsg, err := aesEnc.Decrypt(arrEncrypt)
if err != nil {
	log.Println(arrEncrypt)
	return
}
fmt.Println(string(strMsg))
Output:

abcdef

Jump to

Keyboard shortcuts

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