mchess-server/utils/passphrase.go

30 lines
461 B
Go
Raw Normal View History

2023-06-28 17:51:36 +00:00
package utils
import (
"strings"
)
type Passphrase string
func NewPassphrase() Passphrase {
var phrase string
var word string
var words = 3
2023-07-05 19:15:01 +00:00
//TODO make sure passphrases are unique
2023-06-28 17:51:36 +00:00
for words > 0 {
word = getCleanWord()
phrase = phrase + word + " "
2023-06-28 17:51:36 +00:00
words -= 1
}
return Passphrase(strings.TrimSpace(phrase))
}
func NewPassphraseFromString(s string) Passphrase {
return Passphrase(s)
}
2023-06-28 17:51:36 +00:00
func (p Passphrase) String() string {
return string(p)
}