Go Language - AES Encryption And Decryption Example
Advanced Encryption Standard is a symmetric encryption algorithm. AES encryption is used by the U.S. for securing sensitive but unclassified material, so we can say it is enough secure. I t allows 128 bit, 192 bit and 256-bit encryption. Symmetric encryption is very fast as compared to asymmetric encryption and are used in systems such as database system. The following illustration highlights how symmetric cryptography works: Example: package main import ( "crypto/aes" "crypto/cipher" "crypto/rand" "encoding/hex" "fmt" "io" ) func main() { //generate a random 32 byte key key := GenerateRandomKey() //your secret text secret := "This is my password" //encryption encrypted := encrypt(secret, key) fmt.Printf( "encrypted data: %s\n" , encrypted) //decryption decrypted := decrypt(encrypted, key) fmt.Printf( "decrypted data: %s\n" , decry