diff options
| author | ishaan <contact@ishaan.cc> | 2026-07-13 10:13:54 +0530 |
|---|---|---|
| committer | ishaan <contact@ishaan.cc> | 2026-07-13 10:13:54 +0530 |
| commit | 388971e7a86be97f6a7412cd1d526016bc4e14ce (patch) | |
| tree | dda2a60ce6907770a0962f7233136cd2d1e1e232 /internal/utils/utils.go | |
| parent | 6fa6f58e43a13747388973fe0ec7018a2f0683df (diff) | |
w
Diffstat (limited to 'internal/utils/utils.go')
| -rw-r--r-- | internal/utils/utils.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/internal/utils/utils.go b/internal/utils/utils.go index be3f3ad..96ca0f0 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -1,6 +1,7 @@ package utils import ( + "crypto/rand" "fmt" "os" "os/signal" @@ -47,3 +48,27 @@ func TakeSecureUserInput() ([]byte, error) { return sensInfo, nil } + +func RandomLetters(n int) []byte { + const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" + b := make([]byte, n) + if _, err := rand.Read(b); err != nil { + return nil + } + for i := range b { + b[i] = alphabet[int(b[i])%len(alphabet)] + } + return b +} + +func RandomLettersNumbers(n int) []byte { + const alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" + b := make([]byte, n) + if _, err := rand.Read(b); err != nil { + return nil + } + for i := range b { + b[i] = alphabet[int(b[i])%len(alphabet)] + } + return b +} |