This commit is contained in:
Your Name 2023-10-07 09:36:54 -04:00
parent 21646ee66c
commit caa80fd73b
2 changed files with 13 additions and 13 deletions

View File

@ -13,6 +13,7 @@ import (
func TestUsers(t *testing.T) { func TestUsers(t *testing.T) {
var email string var email string
c.testing = true c.testing = true
generatePassword(16)
flag.StringVar(&email, "email", "", "Email address to use for registration test") flag.StringVar(&email, "email", "", "Email address to use for registration test")
flag.Parse() flag.Parse()

View File

@ -3,28 +3,27 @@ package scsusers
import ( import (
"crypto/rand" "crypto/rand"
"encoding/base32" "encoding/base32"
"log"
mr "math/rand" mr "math/rand"
"time" "time"
"unicode" "unicode"
) )
func flipCoin() bool { func flipCoin() bool {
r:=mr.New(mr.NewSource(time.Now().Unix())) r := mr.New(mr.NewSource(time.Now().UnixNano()))
return r.Intn(2)==1 return r.Intn(3) == 1
} }
func scrambleCase(in []byte) []byte { func scrambleCase(in []byte) []byte {
var out []byte var out []byte
for _, x := range string(in) { for _, x := range string(in) {
if unicode.IsUpper(x) { if unicode.IsUpper(x) && flipCoin() {
if flipCoin() {
out = append(out, byte(x))
} else {
out = append(out, byte(unicode.ToLower(x))) out = append(out, byte(unicode.ToLower(x)))
} else {
} out = append(out, byte(x))
} }
} }
log.Printf("scrambleCase in %s out %s", in, out)
return out return out
} }