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
+10.6k Golang : Resolve domain name to IP4 and IP6 addresses.
+26.8k Golang : Convert file content into array of bytes
+4.4k Golang : Valued expressions and functions example
+7.7k Golang : Generate human readable password
+20.2k Golang : How to get struct tag and use field name to retrieve data?
+10k Golang : Get escape characters \u form from unicode characters
+6.7k Golang : Derive cryptographic key from passwords with Argon2
+18.6k Golang : Find IP address from string
+39.2k Golang : How to read CSV file
+7.2k Golang : Null and nil value
+21.4k Curl usage examples with Golang
+13.6k Golang : Strings comparison