Golang crypto/aes.KeySizeError() function example
package crypto/aes
Golang : crypto/aes.KeySizeError() function usage example
package main
import (
"crypto/aes"
"fmt"
)
func main() {
key := "opensesame45A" // not in 16, 24 or 32 bytes. Will generate error because key only have 13 bytes
_, err := aes.NewCipher([]byte(key))
if err != nil {
fmt.Printf("%s\n", err.Error()) // KeySizeError function will return error message in string format
}
}
Output :
crypto/aes: invalid key size 13
Reference :
Advertisement
Something interesting
Tutorials
+6.9k Golang : Calculate BMI and risk category
+11.3k Golang : How to use if, eq and print properly in html template
+14.5k How to automatically restart your crashed Golang server
+29.5k Golang : Login(Authenticate) with Facebook example
+19.5k Golang : Example for DSA(Digital Signature Algorithm) package functions
+15k Golang : How do I get the local IP (non-loopback) address ?
+6.8k Get Facebook friends working in same company
+4.7k Unix/Linux : How to pipe/save output of a command to file?
+11k Golang : Generate random elements without repetition or duplicate
+9.6k Golang : How to generate Code 39 barcode?
+15.9k Golang : Get file permission
+4.9k Python : Find out the variable type and determine the type with simple test