This commit is contained in:
2026-03-02 01:52:10 +07:00
parent 4280d5376a
commit a044093747
4 changed files with 29 additions and 11 deletions
+5
View File
@@ -0,0 +1,5 @@
package password
type IPasswordGenerator interface {
GeneratePassword(length int) string
}
+8 -2
View File
@@ -6,8 +6,14 @@ var (
letters = []rune("abcdefghijklmnopqrstuvwxyz123456789")
)
func GenPass(n int) string {
b := make([]rune, n)
type service struct{}
func NewPasswordGenerator() IPasswordGenerator {
return &service{}
}
func (s *service) GeneratePassword(length int) string {
b := make([]rune, length)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}