Refactor and simplify package structure and interfaces.
Reorganize code by removing unused files, restructuring package organization, and updating import references to new paths. This simplifies handling of smart and protocol-related operations, improves maintainability, and eliminates redundancy.
This commit is contained in:
15
pkg/utils/crypto.go
Normal file
15
pkg/utils/crypto.go
Normal file
@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/hmac"
|
||||
"crypto/md5"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func GenerateVerifyKey(key string) string {
|
||||
mac := hmac.New(md5.New, []byte(key))
|
||||
|
||||
mac.Write([]byte(key))
|
||||
|
||||
return hex.EncodeToString(mac.Sum(nil))
|
||||
}
|
18
pkg/utils/random.go
Normal file
18
pkg/utils/random.go
Normal file
@ -0,0 +1,18 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"math/rand"
|
||||
"time"
|
||||
)
|
||||
|
||||
// seededRand is a source of random numbers seeded with the current time.
|
||||
var seededRand *rand.Rand = rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
|
||||
// randomString generates a random string of the specified length using the given charset.
|
||||
func RandomString(length int, charset string) string {
|
||||
b := make([]byte, length)
|
||||
for i := range b {
|
||||
b[i] = charset[seededRand.Intn(len(charset))]
|
||||
}
|
||||
return string(b)
|
||||
}
|
Reference in New Issue
Block a user