2015-07-17 21:49:39 +00:00
|
|
|
package openssl
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
2017-04-04 21:53:27 +00:00
|
|
|
func ExampleOpenSSL_EncryptString() {
|
2015-07-17 21:49:39 +00:00
|
|
|
plaintext := "Hello World!"
|
|
|
|
passphrase := "z4yH36a6zerhfE5427ZV"
|
|
|
|
|
|
|
|
o := New()
|
|
|
|
|
|
|
|
enc, err := o.EncryptString(passphrase, plaintext)
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("An error occurred: %s\n", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Printf("Encrypted text: %s\n", string(enc))
|
|
|
|
}
|
|
|
|
|
2017-04-04 21:53:27 +00:00
|
|
|
func ExampleOpenSSL_DecryptString() {
|
2015-07-17 21:49:39 +00:00
|
|
|
opensslEncrypted := "U2FsdGVkX19ZM5qQJGe/d5A/4pccgH+arBGTp+QnWPU="
|
|
|
|
passphrase := "z4yH36a6zerhfE5427ZV"
|
|
|
|
|
|
|
|
o := New()
|
|
|
|
|
|
|
|
dec, err := o.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
|
|
|
|
}
|