Cipher algorithms in Golang
Create .env
file in your root directory and add below variables
- CIPHER_PASSWORD
- CIPHER_SALT
Note: Rotate password/salt pair regularly
When encryption runs more than 2^32 times, Nonce is at the risk of a repeat
go get it (pun intended 😸)
go get github.com/junekimdev/cipher
package main
import (
"log"
"github.com/junekimdev/cipher"
)
func main() {
// text to encrypt
encrypted, err := cipher.Encrypt(text)
// encrypted text to decrypt
decrypted, err := cipher.Decrypt(string(encrypted))
////---- decrypted == text
// a file to encrypt
cipher.EncryptFile(plainTextFile1, encryptedFile)
// encrypted text to decrypt
cipher.DecryptFile(encryptedFile, plainTextFile2)
////---- plainTextFile1 == plainTextFile2
}