initital commit
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
package handlers
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// GenerateKey produces a license key in the format XXXX-XXXX-XXXX-XXXX
|
||||
func GenerateKey() string {
|
||||
b := make([]byte, 8)
|
||||
rand.Read(b)
|
||||
hex := fmt.Sprintf("%X", b)
|
||||
parts := []string{
|
||||
hex[0:4], hex[4:8], hex[8:12], hex[12:16],
|
||||
}
|
||||
return strings.Join(parts, "-")
|
||||
}
|
||||
Reference in New Issue
Block a user