Skip to content

nathanhex/aes256

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aes256

import "github.com/mkmueller/aes256"

The aes256 package provides simplified encryption and decryption functions using the standard crypto/aes package. It implements a 256 bit key length and the GCM cipher. The key may be a string of at least one character with an optional hash iteration value. The encrypted output may be a byte slice or a base-64 encoded string.

aes256.go

func Decrypt(key string, ciphertext []byte) ([]byte, error)

Decrypt accepts a key string and a ciphertext byte array. It returns a decrypted byte array.

func DecryptB64(key string, ciphertext string) ([]byte, error)

DecryptB64 accepts a key string and a base-64 encoded ciphertext string. It returns a decrypted byte array.

func Encrypt(key string, plaintext []byte) ([]byte, error)

Encrypt accepts a key string and a plaintext byte array. It returns an encrypted byte array.

func EncryptB64(key string, plaintext []byte) (string, error)

Encrypt accepts a key string and a plaintext byte array. It returns an encrypted base-64 encoded string.

type Cipher struct {
    // contains filtered or unexported fields
}
func New(key string, rehash ...int) (*Cipher, error)

New accepts a key string and an optional rehash value. The supplied key will be rehashed the number of times indicated by the optional rehash value. A new Cipher instance will be returned.

func (*Cipher) Decrypt

func (ci *Cipher) Decrypt(ciphertext []byte) ([]byte, error)

Decrypt accepts a ciphertext byte array and returns a plaintext byte array.

func (*Cipher) DecryptB64

func (ci *Cipher) DecryptB64(b64str string) ([]byte, error)

DecryptB64 accepts a base-64 encoded ciphertext string and returns a decrypted byte array.

func (*Cipher) Encrypt

func (ci *Cipher) Encrypt(plaintext []byte) ([]byte, error)

Encrypt accepts a plaintext byte array and returns an encrypted byte array.

func (*Cipher) EncryptB64

func (ci *Cipher) EncryptB64(plaintext []byte) (string, error)

EncryptB64 accepts a plaintext byte array and returns an encrypted base-64 encoded ciphertext string.


Generated by godoc2md

About

Simplified encryption and decryption functions using the standard crypto/aes package

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Go 100.0%