Skip to content
Snippets Groups Projects
Commit 10de62da authored by Francé Wilke's avatar Francé Wilke
Browse files

Put used function back

parent 387dd298
No related branches found
No related tags found
No related merge requests found
package auth
import (
"fmt"
"gitlab.bob.co.za/bob-public-utils/bobgroup-go-utils/handler_utils"
"golang.org/x/crypto/bcrypt"
"math/rand"
"strings"
)
......@@ -30,3 +32,25 @@ func PasswordIsCorrect(password string, hashedPassword string) bool {
err := bcrypt.CompareHashAndPassword([]byte(hashedPassword), []byte(password))
return err == nil
}
// Create a pseudorandom password consisting of two three-letter words and two digits
func RandomPassword() string {
i := rand.Intn(100)
var j int
for {
j = rand.Intn(100)
if j != i {
break
}
}
return fmt.Sprintf("%s%s%s", words[i], words[j], RandomDigitString(2))
}
// Create a pseudorandom string of digits (0-9) with specified length
func RandomDigitString(len int) string {
var str strings.Builder
for i := 0; i < len; i++ {
fmt.Fprintf(&str, "%v", rand.Intn(10))
}
return str.String()
}
package auth
var words = []string{
"act",
"add",
"age",
"air",
"ant",
"ark",
"arm",
"art",
"ash",
"bad",
"bag",
"bar",
"bat",
"bay",
"bed",
"bee",
"big",
"box",
"bus",
"bye",
"can",
"car",
"cat",
"con",
"cow",
"cup",
"day",
"dog",
"ear",
"end",
"eye",
"far",
"fly",
"fox",
"fry",
"fun",
"gap",
"gym",
"hat",
"hip",
"hop",
"ice",
"ink",
"jam",
"jar",
"joy",
"key",
"kit",
"lab",
"law",
"log",
"low",
"man",
"max",
"may",
"net",
"nut",
"oil",
"one",
"out",
"owl",
"own",
"pen",
"pet",
"pie",
"pig",
"pin",
"pro",
"ram",
"rap",
"ray",
"red",
"row",
"sea",
"see",
"sew",
"sit",
"six",
"sky",
"son",
"spy",
"tan",
"tax",
"tea",
"ted",
"tee",
"ten",
"the",
"tin",
"toe",
"top",
"toy",
"tub",
"two",
"way",
"wig",
"yes",
"you",
"zip",
"zoo",
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment