Documentation ¶
Index ¶
- Variables
- func DecryptFile(secret string, m *Msg, dst io.Writer) error
- func DecryptText(secret string, m *Msg) (string, error)
- func Hash(data []byte) []byte
- func Key(secret string, salt []byte) ([]byte, []byte)
- func Random(n int) ([]byte, error)
- func Salt() ([]byte, error)
- type Msg
- type StreamSigner
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrSecret is an error when the secret hash is incorrect. ErrSecret = errors.New("failed secret") // ErrHash is an error when the hash is incorrect. ErrHash = errors.New("failed singer hash") )
Functions ¶
func DecryptFile ¶
DecryptFile writes decrypted content of file with path from Msg.Value, checking Msg.KeyHash to dst using the secret and Msg.Salt.
func DecryptText ¶
DecryptText returns decrypted value from Msg.Value using the secret. Salt in m.Salt is expected
Types ¶
type Msg ¶
type Msg struct { Salt string Value string KeyHash string DataHash string // contains filtered or unexported fields }
Msg is struct with base parameter/results of encryption/decryption.
type StreamSigner ¶
StreamSigner is a wrapper for stream Read/Write and hash sum calculations together.
func NewStreamSigner ¶
func NewStreamSigner(src io.Reader, dst io.Writer) *StreamSigner
NewStreamSigner returns new StreamSigner.
func (*StreamSigner) Read ¶
func (s *StreamSigner) Read(p []byte) (n int, err error)
Read reads data from s.R. It's used for stream encryption.
func (*StreamSigner) ReaderHashSum ¶
func (s *StreamSigner) ReaderHashSum() ([]byte, error)
ReaderHashSum calculates and returns s.R hash.
func (*StreamSigner) Write ¶
func (s *StreamSigner) Write(p []byte) (n int, err error)
Write writes data to s.W. It's used for stream decryption.
func (*StreamSigner) WriterHashSum ¶
func (s *StreamSigner) WriterHashSum() ([]byte, error)
WriterHashSum calculates and returns s.W hash.
Click to show internal directories.
Click to hide internal directories.