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.
22 lines
505 B
22 lines
505 B
package make_key
|
|
|
|
import (
|
|
"io"
|
|
"log"
|
|
"crypto/rand"
|
|
"encoding/base64"
|
|
"fmt"
|
|
)
|
|
|
|
func randReader() io.Reader {
|
|
return rand.Reader
|
|
}
|
|
|
|
func Make_a_key(log log.Logger) {
|
|
// XXTEA key should be 16 bytes total...base64 will padd it...
|
|
key := make([]byte, 12)
|
|
if _, err := io.ReadFull(rand.Reader, key); err != nil {
|
|
log.Fatalf("Failed to generate key: %v", err)
|
|
}
|
|
fmt.Printf("Generated XXTEA key (base64): %s\n", base64.StdEncoding.EncodeToString(key))
|
|
}
|
|
|