mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 04:30:08 +00:00
move extra to NetworkSettings
This commit is contained in:
30
common/crypt/aes.go
Normal file
30
common/crypt/aes.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package crypt
|
||||
|
||||
import (
|
||||
"crypto/aes"
|
||||
"encoding/base64"
|
||||
)
|
||||
|
||||
func AesEncrypt(data []byte, key []byte) (string, error) {
|
||||
a, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
en := make([]byte, 0, len(data))
|
||||
a.Encrypt(en, data)
|
||||
return base64.StdEncoding.EncodeToString(en), nil
|
||||
}
|
||||
|
||||
func AesDecrypt(data string, key []byte) (string, error) {
|
||||
d, err := base64.StdEncoding.DecodeString(data)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
a, err := aes.NewCipher(key)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
de := make([]byte, 0, len(data))
|
||||
a.Decrypt(de, d)
|
||||
return string(de), nil
|
||||
}
|
||||
11
common/crypt/sha.go
Normal file
11
common/crypt/sha.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package crypt
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func GenShaHash(data []byte) string {
|
||||
d := sha256.Sum256(data)
|
||||
return hex.EncodeToString(d[:])
|
||||
}
|
||||
Reference in New Issue
Block a user