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
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+23.9k Golang : Use regular expression to validate domain name
+7.3k Golang : Of hash table and hash map
+4.6k Mac OSX : Get disk partitions' size, type and name
+15k Golang : package is not in GOROOT during compilation
+7.7k Golang : get the current working directory of a running program
+4.9k Python : Find out the variable type and determine the type with simple test
+6.6k Golang : Embedded or data bundling example
+14.4k Golang : How to filter a map's elements for faster lookup
+4.7k Adding Skype actions such as call and chat into web page examples
+5k Linux : How to set root password in Linux Mint