Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrEmptyMessage = errors.New("cryptdo: empty message")
ErrEmptyMessage is caused by trying to decrypt and empty function.
var ErrEmptyPassphase = errors.New("cryptdo: passphrase must not be empty")
ErrEmptyPassphase is returned when the user does not type a passphrase before pressing return.
Functions ¶
func Decrypt ¶
Decrypt decrypts a piece of ciphertext which was encrypted with the Encrypt function. The original plaintext is returned if no error occured during the decryption. It supports passing in ciphertext which was made with previous versions of the library.
The output format and internal details of the cryptography performed is documented in the associated protocol buffers file.
Due to the use of authenticated encryption we need to read the entire ciphertext into memory. Therefore it is recommended to only use this for smaller plaintexts.
func Encrypt ¶
Encrypt takes a plaintext blob and encrypts it with a key based on the passphrase provided. The byte slice returned is suitable for passing in to the Decrypt function with the same passphrase in order to retrieve the data.
The output format and internal details of the cryptography performed is documented in the associated protocol buffers file.
Due to the use of authenticated encryption we need to read the entire plaintext into memory. Therefore it is recommended to only use this for smaller plaintexts.
func ReadPassphrase ¶
ReadPassphrase presents a prompt to the user before allowing them to type a passphrase without echoing the characters they type back to the terminal. It returns ErrEmptyPassphase if the user does not enter a passphrase.
Types ¶
type InvalidNonceError ¶
type InvalidNonceError struct {
// contains filtered or unexported fields
}
InvalidNonceError is caused by a mismatch between the expected nonce length from the encryption algorithm and the actual nonce length provided in the message.
func (*InvalidNonceError) Error ¶
func (i *InvalidNonceError) Error() string
type UnknownVersionError ¶
type UnknownVersionError struct {
// contains filtered or unexported fields
}
UnknownVersionError is caused when a message is too new for the executed version to understand. This will often be caused by a mismatch between two cryptography versions operating on the same data.
func (*UnknownVersionError) Error ¶
func (u *UnknownVersionError) Error() string