encrypt

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package encrypt provides symmetric authenticated encryption using 256-bit AES-GCM with a random nonce.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AesDecrypt

func AesDecrypt(ciphertext []byte, key *[]byte) (plaintext []byte, err error)

AesDecrypt decrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Expects input form nonce|ciphertext|tag where '|' indicates concatenation.

func AesEncrypt

func AesEncrypt(plaintext []byte, key *[]byte) (ciphertext []byte, err error)

AesEncrypt encrypts data using 256-bit AES-GCM. This both hides the content of the data and provides a check that it hasn't been altered. Output takes the form nonce|ciphertext|tag where '|' indicates concatenation.

func Decrypt

func Decrypt(privateKeyPath string, output string) (string, error)

func Encrypt

func Encrypt(publicKeyPath string, output string, data []byte) (encryptedKey, encryptedData string)

Encrypt will incrypt the data

func NewAesEncryptionKey

func NewAesEncryptionKey() *[]byte

NewAesEncryptionKey generates a random 256-bit key for Encrypt() and Decrypt(). It panics if the source of randomness fails.

func ReadRsaPrivateKey

func ReadRsaPrivateKey(key string) *rsa.PrivateKey

ReadRsaPrivateKey sets the private key

func ReadRsaPublicKey

func ReadRsaPublicKey(key string) *rsa.PublicKey

ReadRsaPublicKey sets the public key

func RsaDecrypt

func RsaDecrypt(payload string, key *rsa.PrivateKey) (*[]byte, error)

RsaDecrypt decrypts the data

func RsaEncrypt

func RsaEncrypt(payload *[]byte, key *rsa.PublicKey) (string, error)

RsaEncrypt encrypt data

Types

This section is empty.

Jump to

Keyboard shortcuts

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