encio

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2025 License: MIT Imports: 15 Imported by: 1

README

encio - machine dependent encryption

Package encio provides input/output functions that write encrypted using AES-256-CFB data.

The encryption key is the machine identifier, unique to the operating system.

This makes file non-transferrable between devices.

Encrypted container structure is the following:

|__...__|____________...
0  ^   16   ^
   |        +-- encrypted data
   +----------- 16 bytes IV

Documentation

Overview

Package encio provides input/output functions that write encrypted using AES-256-CFB data.

The encryption key is the machine identifier, unique to the operating system.

This makes file non-transferrable between devices.

Encrypted container structure is the following:

|__...__|____________...
 0  ^   16   ^
    |        +-- encrypted data
    +----------- 16 bytes IV

Index

Constants

This section is empty.

Variables

View Source
var ErrDecrypt = errors.New("decryption error")
View Source
var ErrEmptyID = errors.New("empty id")

Functions

func Create

func Create(filename string, opts ...Option) (io.WriteCloser, error)

Create creates an encrypted file container.

func NewReader

func NewReader(r io.Reader, opts ...Option) (io.Reader, error)

NewReader wraps the ciphertext reader, and returns the reader that a plaintext can be read from.

func NewWriter

func NewWriter(w io.Writer, opts ...Option) (io.WriteCloser, error)

NewWriter wraps the writer and returns the WriteCloser. Any information written to the writer is encrypted with the hashed machineID. WriteCloser must be closed to flush any buffered data.

func Open

func Open(filename string, opts ...Option) (io.ReadCloser, error)

Open opens an encrypted file container.

func SetAppID

func SetAppID(s string) error

SetAppID allows to set the appID, that is used to hash the value of machineID.

Types

type Option added in v0.2.0

type Option func(*options)

func WithID added in v0.2.0

func WithID(override string) Option

WithID allows to override the machineID with a custom value.

Jump to

Keyboard shortcuts

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