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
+15.9k Golang : Read a file line by line
+16k Golang : Get sub string example
+10.3k Golang : Wait and sync.WaitGroup example
+15.8k Golang : Get digits from integer before and after given position example
+11.3k Golang : How to flush a channel before the end of program?
+13.6k Golang : Strings comparison
+5.3k Swift : Convert string array to array example
+7.7k Golang : Command line ticker to show work in progress
+6.5k PHP : Shuffle to display different content or advertisement
+11k Golang : Replace a parameter's value inside a configuration file example
+8.6k Python : Fix SyntaxError: Non-ASCII character in file, but no encoding declared
+11.7k Golang : Gorilla web tool kit secure cookie example