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
+4.1k Javascript : Empty an array example
+9.1k Golang : Gonum standard normal random numbers example
+25.5k Golang : Generate MD5 checksum of a file
+22.7k Golang : Round float to precision example
+10.9k Golang : How to transmit update file to client by HTTP request example
+5.2k Golang : The Tao of importing package
+11.7k Golang : Calculations using complex numbers example
+10.5k Swift : Convert (cast) String to Integer
+29.9k Golang : How to get HTTP request header information?