Documentation ¶
Overview ¶
Package aes256cbc 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
Index ¶
- func Decrypt(passphrase, encrypted []byte) ([]byte, error)
- func DecryptBase64(passphrase, encryptedBase64 []byte) ([]byte, error)
- func DecryptString(passphrase, encryptedBase64String string) (string, error)
- func Encrypt(passphrase, plaintext []byte) ([]byte, error)
- func EncryptBase64(passphrase, plaintext []byte) ([]byte, error)
- func EncryptString(passphrase, plaintextString string) (string, error)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecryptBase64 ¶
DecryptBase64 decrypts a base64 encoded []byte that was encrypted using OpenSSL and AES-256-CBC.
func DecryptString ¶
DecryptString decrypts a base64 encoded string that was encrypted using OpenSSL and AES-256-CBC.
Example ¶
opensslEncrypted := "U2FsdGVkX19ZM5qQJGe/d5A/4pccgH+arBGTp+QnWPU=" passphrase := "z4yH36a6zerhfE5427ZV" dec, err := DecryptString(passphrase, opensslEncrypted) if err != nil { fmt.Printf("An error occurred: %s\n", err) } fmt.Printf("Decrypted text: %s\n", string(dec))
Output: Decrypted text: hallowelt
func Encrypt ¶
Encrypt encrypts a []byte in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm
func EncryptBase64 ¶
EncryptBase64 encrypts a []byte in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm and encode to base64 format.
func EncryptString ¶
EncryptString encrypts a string in a manner compatible to OpenSSL encryption functions using AES-256-CBC as encryption algorithm and encode to base64 format.
Example ¶
plaintext := "Hello World!" passphrase := "z4yH36a6zerhfE5427ZV" enc, err := EncryptString(passphrase, plaintext) if err != nil { fmt.Printf("An error occurred: %s\n", err) } fmt.Printf("Encrypted text: %s\n", string(enc))
Output:
Types ¶
This section is empty.