more
This commit is contained in:
parent
21646ee66c
commit
caa80fd73b
|
@ -13,6 +13,7 @@ import (
|
|||
func TestUsers(t *testing.T) {
|
||||
var email string
|
||||
c.testing = true
|
||||
generatePassword(16)
|
||||
flag.StringVar(&email, "email", "", "Email address to use for registration test")
|
||||
flag.Parse()
|
||||
|
||||
|
|
17
password.go
17
password.go
|
@ -3,28 +3,27 @@ package scsusers
|
|||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base32"
|
||||
"log"
|
||||
mr "math/rand"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
func flipCoin() bool {
|
||||
r:=mr.New(mr.NewSource(time.Now().Unix()))
|
||||
return r.Intn(2)==1
|
||||
|
||||
r := mr.New(mr.NewSource(time.Now().UnixNano()))
|
||||
return r.Intn(3) == 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 {
|
||||
if unicode.IsUpper(x) && flipCoin() {
|
||||
out = append(out, byte(unicode.ToLower(x)))
|
||||
|
||||
}
|
||||
} else {
|
||||
out = append(out, byte(x))
|
||||
}
|
||||
}
|
||||
log.Printf("scrambleCase in %s out %s", in, out)
|
||||
return out
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue