Encryption
Gozen ships with its own helpful encryption and decryption library.
Gozen's encryption services provide a simple, convenient interface for encrypting and decrypting text via AES-256 encryption.
Configuration
Before using Gozen's encrypter, you must set the key configuration option in your .env file. You should use the app key command to generate this variable's value since the command will use go's secure random bytes generator to build a cryptographically secure key for your application.
This key is also used in addition to encrypt your cookies, when using sessions etc.
An example is show below.
import ( "fmt" "system/gozen/encrypt" ) func main() { e := encrypt.New() encryptedValue := e.Encrypt("Hello, World!") fmt.Println("Encrypted:", encryptedValue) decryptedValue, err := e.Decrypt(encryptedValue) if err != nil { fmt.Println("Error during decryption:", err) } fmt.Println("Decrypted:", decryptedValue) }