crypter

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2019 License: MIT Imports: 6 Imported by: 0

README

crypter  GoDoc Build Status

Simple go funcs to crypt data

Examples

import "github.com/dlampsi/crypter"

Entrypt and decrypt secret string

// Set secret
secret := "MySecretPassword556"
// Generate secret salt key 32 symbols
salt := GenerateRandString(32)

// Encrypt secret
encrypted, err := Encrypt([]byte(secret), []byte(salt))
if err != nil {
    // Handle error
}
fmt.Printf("Enrcypted: %s\n", string(encrypted))

// Decrypt secret
decrypted, err := err := Decrypt(encrypted, []byte(salt))
if err != nil {
    // Handle error
}
fmt.Printf("Decrypted: %s\n", string(decrypted))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(data []byte, key []byte) ([]byte, error)

Decrypt data.

func Encrypt

func Encrypt(data []byte, key []byte) ([]byte, error)

Encrypt data.

func GenerateRandString

func GenerateRandString(length int) string

GenerateRandString Generates random string selected length. If length is negative, returnd empty string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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