secret

package
v0.0.0-...-642df0c Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: BSD-3-Clause, MIT Imports: 6 Imported by: 0

README

secret

A simple utility for encrypting and decrypting data in Go. (AES-256-CFB)

Install

go get github.com/tidwall/secret

Example

func main

import "github.com/tidwall/secret"

func main(){
    key := "hello world"
    data := []byte("hello jello")

    encdata, err := secret.Encrypt(key, data)
    if err != nil{
        panic(err)
    }

    decdata, err := secret.Decrypt("hello world", encdata)
    if err != nil{
        panic(err)
    }

    println(string(decdata))
}
// output:
// hello jello

Documentation

Overview

Package secret provides simple utilities for encrypting and decrypting data.

Index

Constants

This section is empty.

Variables

View Source
var ErrDecryptFailed = errors.New("decrypt failed")

ErrDecryptFailed is returned when Decrypt is unable to decrypt due to invalid inputs.

Functions

func Decrypt

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

Decrypt data. Uses AES-256-CFB decrypter.

func Encrypt

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

Encrypt data. Uses AES-256-CFB encrypter.

Types

This section is empty.

Jump to

Keyboard shortcuts

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