aes

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecryptAesCbc

func DecryptAesCbc(key string, cipherText string) (string, error)

DecryptAesCbc returns a decrypted text.

key := "key..."
cipherText := "cipher text..."

// decrypt the cipher text
cipherText, err := aes.DecryptAesCbc(key, cipherText)
if err != nil {
	panic(err)
}

func EncryptAesCbc

func EncryptAesCbc(key string, clearText string) (string, error)

EncryptAesCbc returns a cipher text.

saltSize := 16
salt, err := libcrypto.GenerateSalt(saltSize)
if err != nil {
	t.Errorf("Failed to generate salt: %v", err)
}

// compute a 256-bit password hash with salt and 100000 iterations
key := hash.Pbkdf2Hash256("password", salt, 100000)

clearText := "test to encrypt"

// encrypt the clear text
cipherText, err := aes.EncryptAesCbc(key, clearText)
if err != nil {
	panic(err)
}

func PKCS5Padding

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

PKCS5Padding returns a padded text.

func PKCS5Trimming

func PKCS5Trimming(encrypt []byte) []byte

PKCS5Trimming returns a encrypted bytes without padding.

Types

This section is empty.

Jump to

Keyboard shortcuts

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