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
+5.7k Unix/Linux/MacOSx : Get local IP address
+5.4k Golang : What is StructTag and how to get StructTag's value?
+10.7k Golang : Get currencies exchange rates example
+14.6k Golang : How to get URL port?
+13.4k Golang : Generate Code128 barcode
+12.7k Golang : Add ASCII art to command line application launching process
+9.1k Golang : io.Reader causing panic: runtime error: invalid memory address or nil pointer dereference
+22.2k Golang : Securing password with salt
+20.2k Golang : Count number of digits from given integer value
+27.5k Golang : Convert integer to binary, octal, hexadecimal and back to integer
+15.9k Golang : Get file permission
+6.2k PHP : Get client IP address