aescrypt

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 6 Imported by: 1

README

# go-aescrypt image:https://godoc.org/github.com/Djarvur/go-aescrypt?status.svg["GoDoc",link="http://godoc.org/github.com/Djarvur/go-aescrypt"] image:https://travis-ci.org/Djarvur/go-aescrypt.svg["Build Status",link="https://travis-ci.org/Djarvur/go-aescrypt"] image:https://coveralls.io/repos/Djarvur/go-aescrypt/badge.svg?branch=master&service=github["Coverage Status",link="https://coveralls.io/github/Djarvur/go-aescrypt?branch=master"]

Simple but handy wrappers around AES crypto methods,
hiding the boilerplate code around `crypto/aes` and `crypto/cipher`

## Example

```
	var (
		data = []byte("some sencitive data has to be protected with AES")
		key  = []byte("0123456789ABCDEF")
		iv   = []byte("qwertyuiodfghjkm")
	)

	encData, err := aescrypt.EncryptAESCBCPadded(data, key, iv)
	if err != nil {
		t.Fatal(err)
	}

	decData, err := aescrypt.DecryptAESCBCPadded(encData, key, iv)
	if err != nil {
		t.Fatal(err)
	}

	if !bytes.Equal(data, decData) {
		t.Error("decrypted data is not equal to original")
	}
```

Documentation

Overview

Package aescrypt Simple but handy wrappers around AES crypto methods

Index

Constants

This section is empty.

Variables

View Source
var (
	// Panic was recovered. Will be wrapped with actual panic message.
	ErrRecovered = errors.New("recovered")

	// Data provided are invalid. Will be wrapped with actual error message.
	ErrInvalidInput = errors.New("invalid input")
)

Errors might be returned. They will be wrapped with stacktrace at least, of course.

Functions

func DecryptAESCBC

func DecryptAESCBC(src, key, iv []byte) (dst []byte, err error)

DecryptAESCBC will decrypt your data.

func DecryptAESCBCPadded

func DecryptAESCBCPadded(src, key, iv []byte) ([]byte, error)

DecryptAESCBCPadded will decrypt your data and trim the padding.

func EncryptAESCBC

func EncryptAESCBC(src, key, iv []byte) ([]byte, error)

EncryptAESCBC will encrypt your data.

func EncryptAESCBCPadded

func EncryptAESCBCPadded(src, key, iv []byte) ([]byte, error)

EncryptAESCBCPadded will pad your data and encrypt them.

func Pkcs7Pad

func Pkcs7Pad(data []byte, blocklen int) ([]byte, error)

Pkcs7Pad will pad your data.

func Pkcs7Unpad

func Pkcs7Unpad(data []byte, blocklen int) ([]byte, error)

Pkcs7Unpad will trim the padding from your data.

Types

This section is empty.

Jump to

Keyboard shortcuts

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