dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

commit fab728ad65dbd94dc32c4dbdf07de79267a7ead8
parent f0d0593575b4f01b4ce1fee85dd1707f11d712f7
Author: n0tr1v <n0tr1v@protonmail.com>
Date:   Thu, 10 Nov 2022 15:55:00 -0800

simplify code

Diffstat:
Mpkg/utils/utils.go | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/pkg/utils/utils.go b/pkg/utils/utils.go @@ -204,20 +204,20 @@ func ShortDisplayID(size int64) string { // GenerateToken generate a random 32 bytes hex token func GenerateToken() string { - b := make([]byte, 32) - _, _ = rand.Read(b) - return hex.EncodeToString(b) + return generateToken(32) } // GenerateToken1 ... func GenerateToken1() string { - b := make([]byte, 10) - _, _ = rand.Read(b) - return hex.EncodeToString(b) + return generateToken(10) } func GenerateToken2() string { - b := make([]byte, 3) + return generateToken(3) +} + +func generateToken(n int) string { + b := make([]byte, n) _, _ = rand.Read(b) return hex.EncodeToString(b) }