You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
405 B
25 lines
405 B
package main
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
"fmt"
|
|
)
|
|
|
|
func generateKey() ([]byte, error) {
|
|
key := make([]byte, 16)
|
|
_, err := rand.Read(key)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return key, nil
|
|
}
|
|
|
|
func main() {
|
|
key, err := generateKey()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
fmt.Println("Generated 32-byte key (hex):", hex.EncodeToString(key))
|
|
}
|
|
|