secretdata

package module
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: MIT Imports: 8 Imported by: 1

README

Secret Data

Easy the encrypting and decrypting a dataset.

Supported Go versions

Our support of Go versions is aligned with Go's version release policy. So we will support a major version of Go until there are two newer major releases.



Install

With a correctly configured Go toolchain:

go get -u github.com/dmalix/secretdata

Algorithm

When encrypting and decrypting a dataset, the secret key is forced hashed to generate a 32-byte key for use with AES-256. The Secret Data library uses AEAD, an encryption mode that provides authenticated encryption of associated data. For a description of the methodology, see https://en.wikipedia.org/wiki/Authenticated_encryption

Quick Start

Create a new Secret Data instance and set a secret key:

secretDataInstance := secretdata.NewSecretData("secret")

Encrypt a dataset:

dataset := []byte("dataset")
encryptedData, err := secretDataInstance.Encrypt(dataset)
if err != nil {
   log.Fatal(err)
}

And decrypt a dataset:

decryptedData, err := secretDataInstance.Decrypt(encryptedData)
if err != nil {
   log.Fatal(err)
}

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker.

Secure

If you discover any security related issues, please email dmalix@yahoo.com instead of using the issue tracker.

Author

DmAlix

License

This project is licensed under the MIT license. See the LICENSE file for more info.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cipher

type Cipher struct {
	SecretKey string
}

func NewSecretData

func NewSecretData(
	SecretKey string) *Cipher

func (Cipher) Decrypt

func (c Cipher) Decrypt(data []byte) ([]byte, error)

func (Cipher) Encrypt

func (c Cipher) Encrypt(data []byte) ([]byte, error)

type MockDescription

type MockDescription struct {
	Props    struct{}
	Expected struct {
		Error error
	}
}
var MockData MockDescription

func (*MockDescription) Decrypt

func (s *MockDescription) Decrypt(_ []byte) ([]byte, error)

func (*MockDescription) Encrypt

func (s *MockDescription) Encrypt(_ []byte) ([]byte, error)

type SecretData added in v0.1.2

type SecretData interface {
	Encrypt(data []byte) ([]byte, error)
	Decrypt(data []byte) ([]byte, error)
}

Jump to

Keyboard shortcuts

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