aes

package
v0.0.0-...-2770a49 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2015 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(crypted, key []byte) ([]byte, error)

********Aes 解密函数,注意key与加密函数必须一样

func AesEncrypt

func AesEncrypt(origData, key []byte) ([]byte, error)
func main() {
	testAes()
}
func testAes() {
	// AES-128。key长度:16, 24, 32 bytes 对应 AES-128, AES-192, AES-256
	key := []byte("sfe023f_9fd&fwfl")
	result, err := AesEncrypt([]byte("polaris@studygolandfbfgbfb fb fbfxdb fb"), key)
	if err != nil {
		panic(err)
	}
	fmt.Println(result)
	fmt.Println(base64.StdEncoding.EncodeToString(result))
	origData, err := AesDecrypt(result, key)
	if err != nil {
		panic(err)
	}
	fmt.Println(string(origData))
}

********Aes 加密函数,注意key必须是16/24/32 bytes

func PKCS5Padding

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

func PKCS5UnPadding

func PKCS5UnPadding(origData []byte) []byte

func ZeroPadding

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

********

func ZeroUnPadding

func ZeroUnPadding(origData []byte) []byte

Types

This section is empty.

Jump to

Keyboard shortcuts

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