fcrypt

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2024 License: BSD-3-Clause Imports: 12 Imported by: 0

README

Fcrypt

Go Report Card GoDoc

Fcrypt is a flexible and secure encryption package for Go, providing easy-to-use functions for encrypting and decrypting data using AES-GCM (Galois/Counter Mode). This package is designed for simplicity and security, making it suitable for various applications requiring data protection.

Features

  • Encrypt and decrypt data with AES-GCM.
  • Stream encryption and decryption.
  • Encrypt large data and files in chunks.
  • Key rotation and re-encryption support.
  • Extensible key management with an interface for different key types.
  • Hashing functions using SHA3-256 and BLAKE2b.

Installation

To install Fcrypt, use go get:

go get github.com/swayedev/fcrypt

Usage

Basic Encryption and Decryption

Here's how you can encrypt and decrypt data using Fcrypt:

package main

import (
    "fmt"
    "log"

    "github.com/swayedev/fcrypt"
)

func main() {
    passphrase := "your-secure-passphrase"
    data := []byte("Sensitive data here")

    // Generate salt
    salt, err := fcrypt.GenerateSalt(16)
    if err != nil {
        log.Fatalf("Failed to generate salt: %v", err)
    }

    // Generate key
    key, err := fcrypt.GenerateKey(passphrase, salt, fcrypt.DefaultKeyLength)
    if err != nil {
        log.Fatalf("Failed to generate key: %v", err)
    }

    // Encrypt data
    encryptedData, err := fcrypt.Encrypt(data, key)
    if err != nil {
        log.Fatalf("Failed to encrypt data: %v", err)
    }

    // Decrypt data
    decryptedData, err := fcrypt.Decrypt(encryptedData, key)
    if err != nil {
        log.Fatalf("Failed to decrypt data: %v", err)
    }

    fmt.Printf("Original data: %s\n", data)
    fmt.Printf("Decrypted data: %s\n", decryptedData)
}
Stream Encryption and Decryption

Fcrypt supports stream encryption and decryption for large data:

package main

import (
    "bytes"
    "io"
    "log"
    "os"

    "github.com/swayedev/fcrypt"
)

func main() {
    passphrase := "your-secure-passphrase"

    // Generate salt
    salt, err := fcrypt.GenerateSalt(16)
    if err != nil {
        log.Fatalf("Failed to generate salt: %v", err)
    }

    // Generate key
    key, err := fcrypt.GenerateKey(passphrase, salt, fcrypt.DefaultKeyLength)
    if err != nil {
        log.Fatalf("Failed to generate key: %v", err)
    }

    // Open file to encrypt
    file, err := os.Open("largefile.txt")
    if err != nil {
        log.Fatalf("Failed to open file: %v", err)
    }
    defer file.Close()

    // Encrypt file stream
    encryptedStream, err := fcrypt.StreamEncrypt(file, key)
    if err != nil {
        log.Fatalf("Failed to encrypt file stream: %v", err)
    }

    // For demonstration, read the encrypted stream into a buffer
    encryptedData, err := io.ReadAll(encryptedStream)
    if err != nil {
        log.Fatalf("Failed to read encrypted stream: %v", err)
    }

    // Decrypt the encrypted stream
    decryptedStream, err := fcrypt.StreamDecrypt(bytes.NewReader(encryptedData), key)
    if err != nil {
        log.Fatalf("Failed to decrypt file stream: %v", err)
    }

    // Read the decrypted data from the stream
    decryptedData, err := io.ReadAll(decryptedStream)
    if err != nil {
        log.Fatalf("Failed to read decrypted stream: %v", err)
    }

    log.Printf("Decrypted data: %s", decryptedData)
}
Encrypting and Decrypting Large Data Files

Fcrypt supports encrypting and decrypting large data files in chunks:

package main

import (
    "log"
    "os"

    "github.com/swayedev/fcrypt"
)

func main() {
    passphrase := "your-secure-passphrase"

    // Generate salt
    salt, err := fcrypt.GenerateSalt(16)
    if err != nil {
        log.Fatalf("Failed to generate salt: %v", err)
    }

    // Generate key
    key, err := fcrypt.GenerateKey(passphrase, salt, fcrypt.DefaultKeyLength)
    if err != nil {
        log.Fatalf("Failed to generate key: %v", err)
    }

    // Open file to encrypt
    inputFile, err := os.Open("largefile.txt")
    if err != nil {
        log.Fatalf("Failed to open file: %v", err)
    }
    defer inputFile.Close()

    // Encrypt file
    if err := fcrypt.EncryptFileToFile(inputFile, key, 4096, "largefile.encrypted"); err != nil {
        log.Fatalf("Failed to encrypt file: %v", err)
    }

    // Decrypt file
    if err := fcrypt.DecryptFileToFile("largefile.encrypted", "largefile.decrypted", key, 4096); err != nil {
        log.Fatalf("Failed to decrypt file: %v", err)
    }
}
Key Rotation and Re-Encryption

Fcrypt also supports key rotation and re-encryption:

package main

import (
    "fmt"
    "log"

    "github.com/swayedev/fcrypt"
)

func main() {
    passphrase := "your-secure-passphrase"
    keyStore := make(map[string]fcrypt.Key)

    // Rotate key
    version, err := fcrypt.RotateKey(passphrase, keyStore, fcrypt.DefaultKeyLength)
    if err != nil {
        log.Fatalf("Failed to rotate key: %v", err)
    }

    oldKey := keyStore[version]

    data := []byte("Sensitive data here")

    // Encrypt data with the old key
    encryptedData, err := fcrypt.Encrypt(data, oldKey.KeyBytes())
    if err != nil {
        log.Fatalf("Failed to encrypt data: %v", err)
    }

    // Rotate key again
    newVersion, err := fcrypt.RotateKey(passphrase, keyStore, fcrypt.DefaultKeyLength)
    if err != nil {
        log.Fatalf("Failed to rotate key: %v", err)
    }

    newKey := keyStore[newVersion]

    // Re-encrypt data with the new key
    reEncryptedData, err := fcrypt.ReEncrypt(encryptedData, oldKey.KeyBytes(), newKey.KeyBytes())
    if err != nil {
        log.Fatalf("Failed to re-encrypt data: %v", err)
    }

    // Decrypt data with the new key
    decryptedData, err := fcrypt.Decrypt(reEncryptedData, newKey.KeyBytes())
    if err != nil {
        log.Fatalf("Failed to decrypt data: %v", err)
    }

    fmt.Printf("Original data: %s\n", data)
    fmt.Printf("Decrypted data: %s\n", decryptedData)
}
Hashing Functions

Fcrypt includes hashing functions using SHA3-256 and BLAKE2b:

package main

import (
    "fmt"
    "os"
    "strings"

    "github.com/swayedev/fcrypt"
)

func main() {
    data := "Sensitive data here"

    // Hash string to string using SHA3-256
    hashedStringSHA3 := fcrypt.HashStringToStringSHA3(data)
    fmt.Printf("SHA3-256 Hashed string: %s\n", hashedStringSHA3)

    // Hash string to byte array using SHA3-256
    hashedArraySHA3 := fcrypt.HashStringSHA3(data)
    fmt.Printf("SHA3-256 Hashed array: %x\n", hashedArraySHA3)

    // Hash byte slice using SHA3-256
    hashedBytesSHA3 := fcrypt.HashBytesSHA3([]byte(data))
    fmt.Printf("SHA3-256 Hashed bytes: %x\n", hashedBytesSHA3)

    // Hash file using SHA3-256
    file, err := os.Open("largefile.txt")
    if err != nil {
        fmt.Printf("Failed to open file: %v\n", err)
        return
    }
    defer file.Close()
    hashedFileSHA3, err := fcrypt.HashFileSHA3(file)
    if err != nil {
        fmt.Printf("Failed to hash file: %v\n", err)
        return
    }
    fmt.Printf("SHA3-256 Hashed file: %x\n", hashedFileSHA3)

    // Hash string to string using BLAKE2b-512
    reader := strings.NewReader(data)
    hashedStringBlake2b512, err := fcrypt.HashWithBlake2b512(reader, nil)
    if err != nil {
        fmt.Printf("Failed to hash string with BLAKE2b-512: %v\n", err)
        return
    }
    fmt.Printf("BLAKE2b-512 Hashed string: %x\n", hashedStringBlake2b512)
}

API Reference

Types
  • Key: Interface for handling encryption keys.
  • FcryptKey: Implementation of the Key interface using scrypt.
Constants
  • MinKeyLength: Minimum key length (16 bytes).
  • DefaultKeyLength: Default length for keys (32 bytes).
  • ScryptN, ScryptR, ScryptP: Parameters for the scrypt key derivation function.
  • MinNonceSize: Minimum nonce size (12 bytes).
  • GCMNonceSize: Size of the nonce used in GCM mode.
Error Variables
  • ErrCiphertextTooShort: Error message for short ciphertext.
  • ErrKeyLengthTooShort: Error message for short key length.
  • ErrFailedToCreateCipher: Error message for failing to create a cipher.
  • ErrFailedToCreateGCM: Error message for failing to create GCM.
  • ErrFailedToCreateFile: Error message for failing to create a file.
  • ErrFailedToReadData: Error message for failing to read data.
Functions
  • GenerateSalt(length int) ([]byte, error): Generates a random salt.
  • GenerateKey(passphrase string, salt []byte, keyLength int) ([]byte, error): Generates a key using scrypt.
  • GenerateGCM(key []byte) (cipher.AEAD, cipher.Block, error): Generates a GCM cipher.
  • GenerateGCMWithNonce(key []byte) (cipher.AEAD, cipher.Block, []byte, error): Generates a GCM cipher with a random nonce.
  • Encrypt(data []byte, key []byte) ([]byte, error): Encrypts data.
  • Decrypt(data []byte, key []byte) ([]byte, error): Decrypts data.
  • ReEncrypt(data []byte, oldKey []byte, newKey []byte) ([]byte, error): Re-encrypts data with a new key.
  • StreamEncrypt(data io.Reader, key []byte) (io.Reader, error): Encrypts data stream.
  • StreamDecrypt(data io.Reader, key []byte) (io.Reader, error): Decrypts data stream.
  • StreamReEncrypt(data io.Reader, oldKey []byte, newKey []byte) (io.Reader, error): Re-encrypts data stream with a new key.
  • EncryptFileToFile(data io.Reader, key []byte, chunkSize int, filePath string) error: Encrypts data from a reader and writes it to a file.
  • DecryptFileToFile(encryptedFilePath, decryptedFilePath string, key []byte, chunkSize int) error: Decrypts data from an encrypted file and writes it to a new file.
  • HashBytes(data []byte, hasher hash.Hash) []byte: Hashes a byte slice.
  • HashBytesToString(data []byte, hasher hash.Hash) string: Hashes a byte slice and returns a hexadecimal string.
  • HashString(data string, hasher hash.Hash) []byte: Hashes a string.
  • HashStringToString(data string, hasher hash.Hash) string: Hashes a string and returns a hexadecimal string.
  • HashFile(file *os.File, hasher hash.Hash) ([]byte, error): Hashes the contents of a file.
  • HashBytesSHA3(data []byte) []byte: Hashes a byte slice using SHA3-256.
  • HashBytesToStringSHA3(data []byte) string: Hashes a byte slice using SHA3-256 and returns a hexadecimal string.
  • HashStringSHA3(data string) []byte: Hashes a string using SHA3-256.
  • HashStringToStringSHA3(data string) string: Hashes a string using SHA3-256 and returns a hexadecimal string.
  • HashFileSHA3(file *os.File) ([]byte, error): Hashes the contents of a file using SHA3-256.
  • HashWithBlake2b512(reader io.Reader, key []byte) ([]byte, error): Hashes the contents of an io.Reader using BLAKE2b-512.
  • HashWithBlake2b512NoKey(reader io.Reader) ([]byte, error): Hashes the contents of an io.Reader using BLAKE2b-512 without a key.
  • HashWithBlake2b256(reader io.Reader, key []byte) ([]byte, error): Hashes the contents of an io.Reader using BLAKE2b-256.
  • HashWithBlake2b256NoKey(reader io.Reader) ([]byte, error): Hashes the contents of an io.Reader using BLAKE2b-256 without a key.
  • RotateKey(passphrase string, store map[string]Key, keyLength int) (string, error): Rotates the encryption key.

License

Fcrypt is released under the BSD-3-Clause License. See the LICENSE file for details.

Contributing

Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.

Version

Current version: 0.2.2

Authors

  • Swaye Chateau (swayechateau) - Initial work

Changelog

Detailed changes for each version are documented in the CHANGELOG.md file.

Documentation

Index

Constants

View Source
const (
	// MinKeyLength is the minimum length of the encryption key in bytes.
	MinKeyLength = 16
	// DefaultKeyLength is the default length of the encryption key in bytes.
	DefaultKeyLength = 32
	// ScryptN is the CPU/memory cost parameter for scrypt.
	ScryptN = 32768
	// ScryptR is the block size parameter for scrypt.
	ScryptR = 8
	// ScryptP is the parallelization parameter for scrypt.
	ScryptP = 1
	// MinNonceSize is the minimum size of the nonce in bytes.
	MinNonceSize = 12
	// GCMNonceSize is the size of the nonce used in GCM mode.
	GCMNonceSize = 12
)

Constants and errors

Variables

View Source
var (
	ErrCiphertextTooShort   = errors.New("ciphertext too short")
	ErrKeyLengthTooShort    = errors.New("key length too short")
	ErrFailedToCreateCipher = errors.New("failed to create new cipher")
	ErrFailedToCreateGCM    = errors.New("failed to create new GCM")
	ErrFailedToCreateFile   = errors.New("failed to create file")
	ErrFailedToReadData     = errors.New("failed to read data")
)

Error variables

Functions

func Decrypt

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

Decrypt decrypts the given ciphertext using the provided key. It returns the plaintext or an error if decryption fails.

func DecryptChunk

func DecryptChunk(block cipher.Block, encryptedChunk []byte, nonce []byte) ([]byte, error)

DecryptChunk decrypts an encrypted chunk of data using the provided block cipher, nonce, and encrypted chunk. It returns the decrypted data or an error if decryption fails.

func DecryptFileToFile

func DecryptFileToFile(encryptedFilePath, decryptedFilePath string, key []byte, chunkSize int) error

DecryptFileToFile decrypts the contents of an encrypted file and writes the decrypted data to a new file. It takes the path of the encrypted file, the path of the decrypted file, the encryption key, and the chunk size as parameters. The function reads the encrypted file in chunks, decrypts each chunk using AES-GCM encryption, and writes the decrypted data to the new file. It returns an error if any operation fails.

func Encrypt

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

Encrypt encrypts the given data using the provided key and returns the encrypted result. It uses the GCM mode of operation for encryption. The nonce is randomly generated and prepended to the encrypted data.

func EncryptChunk

func EncryptChunk(block cipher.Block, plaintext []byte, nonce []byte) ([]byte, error)

EncryptChunk encrypts the given plaintext using the provided block cipher and nonce. It returns the ciphertext and an error, if any.

func EncryptFileToFile

func EncryptFileToFile(data io.Reader, key []byte, chunkSize int, filePath string) error

EncryptFileToFile encrypts the data from the given reader using the provided key and writes it to the specified file. The encryption is done in chunks of the specified size. It uses AES encryption with GCM mode. The function returns an error if any operation fails.

func GenerateGCM

func GenerateGCM(key []byte) (gcm cipher.AEAD, block cipher.Block, err error)

GenerateGCM generates a Galois/Counter Mode (GCM) cipher.AEAD and cipher.Block using the provided key. It returns the generated gcm, block, and any error encountered during the process.

func GenerateGCMWithNonce added in v0.2.0

func GenerateGCMWithNonce(key []byte) (gcm cipher.AEAD, block cipher.Block, nonce []byte, err error)

GenerateGCMWithNonce generates a Galois/Counter Mode (GCM) cipher with a random nonce. It takes a key as input and returns the GCM cipher, the underlying block cipher, the generated nonce, and any error that occurred during the process.

func GenerateKey

func GenerateKey(passphrase string, salt []byte, keyLength int) ([]byte, error)

GenerateKey generates a key using the provided passphrase, salt, and key length. It uses the scrypt key derivation function to derive the key from the passphrase and salt. The key length specifies the desired length of the generated key in bytes. Returns the generated key as a byte slice and any error encountered during the key generation process.

func GenerateSalt

func GenerateSalt(length int) ([]byte, error)

GenerateSalt generates a random salt of the specified length. It uses the crypto/rand package to generate cryptographically secure random bytes. The length parameter specifies the number of bytes to generate. It returns the generated salt as a byte slice and any error encountered during the generation process.

func GenerateSaltAndKey added in v0.2.2

func GenerateSaltAndKey(passphrase string, saltLength int, keyLength int) ([]byte, []byte, error)

GenerateSaltAndKey generates the salt and key using the provided passphrase and key length. It first generates the salt of the specified length and then derives the key using that salt.

func Hash added in v0.2.0

func Hash(reader io.Reader, hasher hash.Hash) ([]byte, error)

Hash calculates the hash of the given io.Reader using the provided hash.Hash.

func HashBytes added in v0.2.0

func HashBytes(data []byte, hasher hash.Hash) []byte

HashBytes calculates the hash of the given byte slice using the provided hash.Hash.

func HashBytesSHA3 added in v0.2.0

func HashBytesSHA3(data []byte) []byte

HashBytesSHA3 calculates the SHA3-256 hash of the given data. It uses the HashBytes function with a new SHA3-256 hash instance.

func HashBytesToString added in v0.2.0

func HashBytesToString(data []byte, hasher hash.Hash) string

HashBytesToString calculates the hash of the given byte slice using the provided hash.Hash.

func HashBytesToStringSHA3 added in v0.2.0

func HashBytesToStringSHA3(data []byte) string

HashBytesToStringSHA3 converts a byte slice to a string representation of its SHA3 hash. It takes a byte slice `data` as input and returns the hexadecimal string representation of the SHA3 hash.

func HashFile added in v0.2.0

func HashFile(file *os.File, hasher hash.Hash) ([]byte, error)

HashFile calculates the hash of the given file using the provided hash.Hash.

func HashFileSHA3 added in v0.2.0

func HashFileSHA3(file *os.File) ([]byte, error)

HashFileSHA3 calculates the SHA3-256 hash of the given file. It takes a *os.File as input and returns the hash as a byte slice. If an error occurs during the hashing process, it is returned as the second value.

func HashString

func HashString(data string, hasher hash.Hash) []byte

HashString calculates the hash of the given string using the provided hash.Hash.

func HashStringSHA3 added in v0.2.0

func HashStringSHA3(data string) []byte

HashStringSHA3 hashes the given string using SHA3-256 algorithm and returns the resulting hash as a byte slice.

func HashStringToString

func HashStringToString(data string, hasher hash.Hash) string

HashStringToString calculates the hash of the given string using the provided hash.Hash.

func HashStringToStringSHA3 added in v0.2.0

func HashStringToStringSHA3(data string) string

HashStringToStringSHA3 hashes a string using SHA3-256 algorithm and returns the hashed value as a string.

func HashWithBlake2b256 added in v0.2.0

func HashWithBlake2b256(reader io.Reader, key []byte) ([]byte, error)

HashWithBlake2b256 hashes the contents of the provided io.Reader using BLAKE2b-256. It returns the computed hash as a byte slice.

func HashWithBlake2b256NoKey added in v0.2.0

func HashWithBlake2b256NoKey(reader io.Reader) ([]byte, error)

HashWithBlake2b256NoKey calculates the Blake2b-256 hash of the data read from the given reader, without using any key. It is a convenience function that calls HashWithBlake2b256 with a nil key. The resulting hash is returned as a byte slice. If an error occurs during the hashing process, it is returned along with a nil byte slice.

func HashWithBlake2b512 added in v0.2.0

func HashWithBlake2b512(reader io.Reader, key []byte) ([]byte, error)

HashWithBlake2b512 hashes the contents of the provided io.Reader using BLAKE2b-512. It returns the computed hash as a byte slice.

func HashWithBlake2b512NoKey added in v0.2.0

func HashWithBlake2b512NoKey(reader io.Reader) ([]byte, error)

HashWithBlake2b512NoKey calculates the Blake2b-512 hash of the data read from the given reader, without using any key. It internally calls the HashWithBlake2b512 function with a nil key. It returns the hash as a byte slice and any error encountered during the hashing process.

func ReEncrypt

func ReEncrypt(data []byte, oldKey []byte, newKey []byte) ([]byte, error)

ReEncrypt re-encrypts the given data using the oldKey and then encrypts it again using the newKey. It returns the re-encrypted data or an error if the encryption process fails.

func ReEncryptFileToFile added in v0.2.0

func ReEncryptFileToFile(encryptedFilePath, decryptedFilePath string, oldKey []byte, newKey []byte, chunkSize int) error

ReEncryptFileToFile re-encrypts the contents of an encrypted file using a new encryption key and writes the decrypted contents to a new file.

Parameters: - encryptedFilePath: The path to the encrypted file. - decryptedFilePath: The path to the new file where the decrypted contents will be written. - oldKey: The old encryption key used to encrypt the file. - newKey: The new encryption key to be used for re-encryption. - chunkSize: The size of each chunk to be read from the encrypted file.

Returns: - An error if any error occurs during the re-encryption process, or nil if the re-encryption is successful.

Example usage:

err := ReEncryptFileToFile("/path/to/encrypted/file", "/path/to/decrypted/file", oldKey, newKey, 1024)
if err != nil {
	fmt.Println("Error:", err)
}

func StreamDecrypt

func StreamDecrypt(data io.Reader, key []byte) (io.Reader, error)

StreamDecrypt decrypts the data from the given io.Reader using the provided key. It returns an io.Reader that can be used to read the decrypted data, along with any error encountered. The decryption is performed using the AES-GCM mode of operation. The key parameter is the secret key used for decryption. The data parameter is the encrypted data that needs to be decrypted. The returned io.Reader can be used to read the decrypted data. If an error occurs during decryption, it is returned along with a nil io.Reader.

func StreamEncrypt

func StreamEncrypt(data io.Reader, key []byte) (io.Reader, error)

StreamEncrypt takes an input data stream and a key, and returns an encrypted data stream along with any error encountered. The function generates a GCM (Galois/Counter Mode) cipher using the provided key, and then generates a random nonce. It uses the GCM cipher in CTR (Counter) mode to create a cipher stream reader, which encrypts the input data stream. The encrypted data stream is returned along with a possible error.

func StreamReEncrypt

func StreamReEncrypt(data io.Reader, oldKey []byte, newKey []byte) (io.Reader, error)

StreamReEncrypt re-encrypts the data from the given reader using the oldKey and then encrypts it again using the newKey. It returns an io.Reader containing the re-encrypted data. If any error occurs during the decryption or encryption process, it returns nil and the error.

Types

type FcryptKey

type FcryptKey struct {
	// contains filtered or unexported fields
}

ScryptKey struct implements the Key interface

func NewFcryptKey added in v0.2.1

func NewFcryptKey(version string, salt []byte, algo string, key []byte) *FcryptKey

NewFcryptKey creates a new FcryptKey with the specified version, salt, algorithm, and key.

func (*FcryptKey) Algo

func (k *FcryptKey) Algo() string

Algo returns the algorithm used by the FcryptKey.

func (*FcryptKey) KeyBytes

func (k *FcryptKey) KeyBytes() []byte

KeyBytes returns the key bytes of the FcryptKey.

func (*FcryptKey) Salt

func (k *FcryptKey) Salt() []byte

Salt returns the salt value associated with the FcryptKey.

func (*FcryptKey) SetAlgo added in v0.2.1

func (k *FcryptKey) SetAlgo(a string)

SetAlgo sets the encryption algorithm for the FcryptKey. The algorithm should be a string representing the desired encryption algorithm.

func (*FcryptKey) SetAll added in v0.2.1

func (k *FcryptKey) SetAll(v string, s []byte, a string, key []byte)

SetAll sets the values of the FcryptKey struct. It takes in the version string, salt byte slice, algorithm string, and key byte slice as parameters.

func (*FcryptKey) SetKeyBytes added in v0.2.1

func (k *FcryptKey) SetKeyBytes(key []byte)

SetKeyBytes sets the key bytes for the FcryptKey instance. The key parameter is a byte slice containing the key bytes.

func (*FcryptKey) SetSalt added in v0.2.1

func (k *FcryptKey) SetSalt(s []byte)

SetSalt sets the salt value for the FcryptKey. The salt is used as an additional input to the key derivation function, making it harder to perform precomputed dictionary attacks.

func (*FcryptKey) SetVersion added in v0.2.1

func (k *FcryptKey) SetVersion(v string)

SetVersion sets the version of the FcryptKey.

func (*FcryptKey) Version

func (k *FcryptKey) Version() string

Version returns the version of the FcryptKey.

type Key

type Key interface {
	Version() string
	Salt() []byte
	Algo() string
	KeyBytes() []byte
}

Key interface to provide methods for handling encryption keys

Jump to

Keyboard shortcuts

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