Package crypto provides encryption and hashing utilities.
-
Get package:
go get -u github.com/gowww/crypto
-
Import it in your code:
import "github.com/gowww/crypto"
Use NewEncrypter with a 32 bytes long secret key to make a new Encrypter:
encrypter, _ := crypto.NewEncrypter([]byte("secret-key-secret-key-secret-key"))
Use Encrypter.Encrypt or Encrypter.EncryptBase64 to encrypt a value:
encryptedData, _ := encrypter.Encrypt([]byte("data to encrypt"))
Use Encrypter.Decrypt or Encrypter.DecryptBase64 to decrypt a value:
decryptedData, _ := encrypter.Decrypt(encryptedData)