Golang data encryptor package by Saparov
Install from repository
go get github.com/Kesha005/go_encryptor
Encryption and decryption are used to secure data in auth,message systems and in cybersecurity
Firstly we need config our .env file and add there "SECRET_KEY" and "IV_16_KEY"
SECRET_KEY="thismustbe16or24digitkey."
IV_16_KEY="thisis16digitkey"
Import package
import (
"github.com/Kesha005/go_encryptor"
"fmt"
"github.com/joho/godotenv"
)
Encryption and decryption
StringToEncrypt := "Encrypting this string"
godotenv.Load(".env")
fmt.Println(StringToEncrypt)
encText, err := go_encryptor.Encrypt(StringToEncrypt)
if err != nil {
fmt.Println("error encrypting your classified text: ", err)
}
fmt.Println(encText)
// To decrypt the original StringToEncrypt
decText, err := go_encryptor.Decrypt(encText)
if err != nil {
fmt.Println("error decrypting your encrypted text: ", err)
}
fmt.Println(decText)