cryptutil

package
v0.0.0-...-e35fbe1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotEncrypted = errors.New("not an encrypted value")
View Source
var ErrTooMuchDataRead = errors.New("too much data read")
View Source
var Magic = []byte("CRYPT")

Functions

func Decrypt

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

Decrypts a ciphertext encrypted with AES-256-GCM. The first 12 bytes of the ciphertext is assumed to be the IV.

func DecryptOpenSSL

func DecryptOpenSSL(ciphertext, password string) (string, error)

func DecryptWithPassword

func DecryptWithPassword(ciphertext string, password string) (string, error)

Decrypts a base64-encoded ciphertext encrypted with EncryptWithPassword. Returns the plaintext as string.

func Encrypt

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

Encrypts a plaintext with AES-256-GCM. Returns 12 bytes of IV, and then N bytes of ciphertext.

func EncryptIfPlaintext

func EncryptIfPlaintext(plaintext string, password string) (string, error)

Encrypt plaintext if not already encrypted, using EncryptWithPassword.

func EncryptWithPassword

func EncryptWithPassword(plaintext string, password string) (string, error)

Encrypt and base64-encode data using aes-256-gcm and a key derived from a password hashed with PBKDF2. Output is a base64-encoded string with 16 bytes of PBKDF2 salt, 12 bytes of iv, followed by ciphertext.

func ReEncrypt

func ReEncrypt(ciphertext, password string) (string, error)

Decrypt data encrypted with OpenSSL, and re-encrypt with secure parameters.

Types

This section is empty.

Jump to

Keyboard shortcuts

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