From 21646ee66caed636712ffb9446332d2cded6f316 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sat, 7 Oct 2023 09:31:42 -0400 Subject: [PATCH] fix coin flip --- password.go | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/password.go b/password.go index 9850bdc..84a04b2 100644 --- a/password.go +++ b/password.go @@ -3,26 +3,20 @@ package scsusers import ( "crypto/rand" "encoding/base32" + mr "math/rand" + "time" "unicode" ) func flipCoin() bool { - x := make([]byte, 1) - _, err := rand.Read(x) - if err != nil { - return true - } - if uint8(x[0]) % 2==0 { - return true - } - return false + r:=mr.New(mr.NewSource(time.Now().Unix())) + return r.Intn(2)==1 } func scrambleCase(in []byte) []byte { var out []byte for _, x := range string(in) { if unicode.IsUpper(x) { - if flipCoin() { out = append(out, byte(x)) } else {