dcrypto

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 6 Imported by: 10

README

dcrypto

Chat on Slack GitHub license Go Report Card GitHub action standard-readme compliant

A stream-based encryption library

This library is a modified version of the Google Drive client dcrypto package. The current version uses an AES-256 cipher in CTR mode signed with an HMAC using SHA-512. Read more here.

Table of Contents

Install

go get github.com/textileio/dcrypto

Usage

Go to https://godoc.org/github.com/textileio/dcrypto.

License

Apache-2.0

Documentation

Index

Constants

View Source
const PreferedVersion = V1

PreferedVersion is the preferred version of encryption.

Variables

View Source
var MaxHeaderSize = v1.HeaderSize + 4

MaxHeaderSize is the maximum header size of all versions. This many bytes at the beginning of a file should be enough to compute a hash of a local file.

Functions

func Hash

func Hash(r io.Reader, header io.Reader, key []byte, hashFunc func() hash.Hash) ([]byte, error)

Hash will hash of plaintext based on the header of the encrypted file and returns the hash Sum.

func HashWithPassword

func HashWithPassword(r io.Reader, header io.Reader, password []byte, hashFunc func() hash.Hash) ([]byte, error)

HashWithPassword will hash of plaintext based on the header of the encrypted file and returns the hash Sum.

func NewDecrypter

func NewDecrypter(r io.Reader, key []byte) (io.ReadCloser, error)

NewDecrypter returns a decrypting reader based on the version used to encrypt.

func NewDecrypterWithPassword

func NewDecrypterWithPassword(r io.Reader, password []byte) (io.ReadCloser, error)

NewDecrypterWithPassword returns a decrypting reader based on the version used to encrypt.

func NewEncrypter

func NewEncrypter(r io.Reader, key []byte) (io.Reader, error)

NewEncrypter returns an encrypting reader using the PreferedVersion.

func NewEncrypterWithPassword

func NewEncrypterWithPassword(r io.Reader, password []byte) (io.Reader, error)

NewEncrypterWithPassword returns an encrypting reader using the PreferedVersion.

func NewKey

func NewKey() ([]byte, error)

NewKey returns a new random key. The consists of two segments. One for AES and one for HMAC.

Types

type Version

type Version uint32

Version is the version of the en/decryption library used.

const (
	V1 Version = iota
)

These are the different versions of the en/decryption library.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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