mirror of
https://github.com/Awuqing/BackupX.git
synced 2026-08-27 11:10:38 +08:00
first commit
This commit is contained in:
14
server/internal/security/secret.go
Normal file
14
server/internal/security/secret.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package security
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
func GenerateSecret(bytesLength int) (string, error) {
|
||||
buffer := make([]byte, bytesLength)
|
||||
if _, err := rand.Read(buffer); err != nil {
|
||||
return "", err
|
||||
}
|
||||
return base64.RawURLEncoding.EncodeToString(buffer), nil
|
||||
}
|
||||
Reference in New Issue
Block a user