Documentation ¶
Index ¶
- Variables
- func DigestMD5Sum(data []byte) []byte
- func DigestSHA1Sum(data []byte) []byte
- func DigestSHA256Sum(data []byte) []byte
- type DigestFunc
- type OpenSSL
- func (o OpenSSL) DecryptBytes(passphrase string, encryptedBase64Data []byte) ([]byte, error)
- func (o OpenSSL) DecryptString(passphrase, encryptedBase64String string) ([]byte, error)
- func (o OpenSSL) EncryptBytes(passphrase string, plainData []byte) ([]byte, error)
- func (o OpenSSL) EncryptBytesWithSalt(passphrase string, salt, plainData []byte) ([]byte, error)deprecated
- func (o OpenSSL) EncryptBytesWithSaltAndDigestFunc(passphrase string, salt, plainData []byte, hashFunc DigestFunc) ([]byte, error)
- func (o OpenSSL) EncryptString(passphrase, plaintextString string) ([]byte, error)
- func (o OpenSSL) EncryptStringWithSalt(passphrase string, salt []byte, plaintextString string) ([]byte, error)deprecated
- func (o OpenSSL) GenerateSalt() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSalt = errors.New("salt needs to have exactly 8 byte")
ErrInvalidSalt is returned when a salt with a length of != 8 byte is passed
Functions ¶
func DigestMD5Sum ¶
DigestMD5Sum uses the (deprecated) pre-OpenSSL 1.1.0c MD5 digest to create the key
func DigestSHA1Sum ¶
DigestSHA1Sum uses SHA1 digest to create the key
func DigestSHA256Sum ¶
DigestSHA256Sum uses SHA256 digest to create the key which is the default behaviour since OpenSSL 1.1.0c
Types ¶
type DigestFunc ¶
DigestFunc are functions to create a key from the passphrase
type OpenSSL ¶
type OpenSSL struct {
// contains filtered or unexported fields
}
OpenSSL is a helper to generate OpenSSL compatible encryption with autmatic IV derivation and storage. As long as the key is known all data can also get decrypted using OpenSSL CLI. Code from http://dequeue.blogspot.de/2014/11/decrypting-something-encrypted-with.html
func (OpenSSL) DecryptBytes ¶
DecryptBytes takes a slice of bytes with base64 encoded, encrypted data to decrypt
func (OpenSSL) DecryptString ¶
DecryptString decrypts a string that was encrypted using OpenSSL and AES-256-CBC
func (OpenSSL) EncryptBytes ¶
EncryptBytes encrypts a slice of bytes in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm. This function generates a random salt on every execution.
func (OpenSSL) EncryptBytesWithSalt
deprecated
EncryptBytesWithSalt encrypts a slice of bytes in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm. The salt needs to be passed in here which ensures the same result on every execution on cost of a much weaker encryption as with EncryptString.
The salt passed into this function needs to have exactly 8 byte.
If you don't have a good reason to use this, please don't! For more information see this: https://en.wikipedia.org/wiki/Salt_(cryptography)#Common_mistakes
Deprecated: Use EncryptBytesWithSaltAndDigestFunc instead.
func (OpenSSL) EncryptBytesWithSaltAndDigestFunc ¶
func (o OpenSSL) EncryptBytesWithSaltAndDigestFunc(passphrase string, salt, plainData []byte, hashFunc DigestFunc) ([]byte, error)
EncryptBytesWithSaltAndDigestFunc encrypts a slice of bytes in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm. The salt needs to be passed in here which ensures the same result on every execution on cost of a much weaker encryption as with EncryptString.
The salt passed into this function needs to have exactly 8 byte.
The hash function corresponds to the `-md` parameter of OpenSSL. For OpenSSL pre-1.1.0c DigestMD5Sum was the default, since then it is DigestSHA256Sum.
If you don't have a good reason to use this, please don't! For more information see this: https://en.wikipedia.org/wiki/Salt_(cryptography)#Common_mistakes
func (OpenSSL) EncryptString ¶
EncryptString encrypts a string in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm. This function generates a random salt on every execution.
func (OpenSSL) EncryptStringWithSalt
deprecated
func (o OpenSSL) EncryptStringWithSalt(passphrase string, salt []byte, plaintextString string) ([]byte, error)
EncryptStringWithSalt encrypts a string in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm. The salt needs to be passed in here which ensures the same result on every execution on cost of a much weaker encryption as with EncryptString.
The salt passed into this function needs to have exactly 8 byte.
If you don't have a good reason to use this, please don't! For more information see this: https://en.wikipedia.org/wiki/Salt_(cryptography)#Common_mistakes
Deprecated: Use EncryptBytesWithSaltAndDigestFunc instead.
func (OpenSSL) GenerateSalt ¶
GenerateSalt generates a random 8 byte salt