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: 4 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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
⌂ 换网址