encryption

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2023 License: BSD-3-Clause-Clear Imports: 7 Imported by: 1

Documentation

Overview

Example
package main

import (
	"fmt"

	"github.com/stellaraf/go-utils/encryption"
)

func main() {
	passphrase := "super secret password"
	data := "value to encrypt"
	encrypted, err := encryption.Encrypt(passphrase, data)
	if err != nil {
		panic(err)
	}

	decrypted, err := encryption.Decrypt(passphrase, encrypted)
	if err != nil {
		panic(err)
	}
	fmt.Println(decrypted)
}
Output:

value to encrypt

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(passphrase, ciphertext string) (decrypted string, err error)

Decrypt decrypts a cipher that was encrypted using AES-256-GCM encryption.

Usage:

passphrase := "super secret password"
cipherText := "cipher value"
decrypted, err := encryption.Decrypt(passphrase, cipherText)

func Encrypt

func Encrypt(passphrase, plaintext string) (encrypted string, err error)

Encrypt encrypts a given string using AES-256-GCM encryption with a passphrase.

Usage:

passphrase := "super secret password"
value := "value to be encrypted"
encrypted, err := encryption.Encrypt(passphrase, value)

Types

This section is empty.

Jump to

Keyboard shortcuts

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