encryption.go
Overview - encryption.go
This file provides utility functions for encrypting and decrypting data using AES encryption.
Detailed Documentation
Encrypt
- Purpose: Encrypts the given text using the provided key.
- Parameters:
key
([]byte): The encryption key.text
([]byte): The text to be encrypted.
- Returns:
[]byte
: The encrypted ciphertext.error
: An error if encryption fails.
Decrypt
- Purpose: Decrypts the given ciphertext using the provided key.
- Parameters:
key
([]byte): The decryption key.text
([]byte): The ciphertext to be decrypted.
- Returns:
[]byte
: The decrypted plaintext.error
: An error if decryption fails.
Code Examples
// Example of encrypting data
const key = []byte("passphrasewith32chars!");
const plaintext = []byte("sensitive data");
const ciphertext, err = Encrypt(key, plaintext);
// Example of decrypting data
const key = []byte("passphrasewith32chars!");
const plaintext, err = Decrypt(key, ciphertext);
Include in Getting Started: NO