mirror of
https://github.com/ap-pauloafonso/ratio-spoof.git
synced 2026-04-20 16:12:18 +00:00
23 lines
441 B
Go
23 lines
441 B
Go
package generator
|
|
|
|
import (
|
|
"crypto/rand"
|
|
"encoding/hex"
|
|
"strings"
|
|
)
|
|
|
|
func NewDefaultKeyGenerator() (*DefaultKeyGenerator, error) {
|
|
randomBytes := make([]byte, 4)
|
|
rand.Read(randomBytes)
|
|
str := hex.EncodeToString(randomBytes)
|
|
result := strings.ToUpper(str)
|
|
return &DefaultKeyGenerator{generated: result}, nil
|
|
}
|
|
|
|
type DefaultKeyGenerator struct {
|
|
generated string
|
|
}
|
|
|
|
func (d *DefaultKeyGenerator) Key() string {
|
|
return d.generated
|
|
}
|