remove dependency to external base62 package and create own methods in utils

This commit is contained in:
Pascal Fischer
2023-05-16 12:44:26 +02:00
parent a3ee45b79e
commit 2fef52b856
7 changed files with 101 additions and 9 deletions
+3 -2
View File
@@ -7,9 +7,10 @@ import (
"hash/crc32"
"time"
"codeberg.org/ac/base62"
b "github.com/hashicorp/go-secure-stdlib/base62"
"github.com/rs/xid"
"github.com/netbirdio/netbird/util"
)
const (
@@ -71,7 +72,7 @@ func generateNewToken() (string, string, error) {
}
checksum := crc32.ChecksumIEEE([]byte(secret))
encodedChecksum := base62.Encode(checksum)
encodedChecksum := util.EncodeBase62(checksum)
paddedChecksum := fmt.Sprintf("%06s", encodedChecksum)
plainToken := PATPrefix + secret + paddedChecksum
hashedToken := sha256.Sum256([]byte(plainToken))