Refactor: Rename NanoKVM to BatchuKVM and update server URL
This commit is contained in:
30
server/utils/encrypt.go
Normal file
30
server/utils/encrypt.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/mervick/aes-everywhere/go/aes256"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
// SecretKey is only used to prevent the data from being transmitted in plaintext.
|
||||
const SecretKey = "NanoKVM-KOREA-TestKey-2512092155"
|
||||
|
||||
func Decrypt(ciphertext string) (string, error) {
|
||||
if ciphertext == "" {
|
||||
return "", nil
|
||||
}
|
||||
|
||||
decrypt := aes256.Decrypt(ciphertext, SecretKey)
|
||||
return decrypt, nil
|
||||
}
|
||||
|
||||
func DecodeDecrypt(data string) (string, error) {
|
||||
ciphertext, err := url.QueryUnescape(data)
|
||||
if err != nil {
|
||||
log.Errorf("decode ciphertext failed: %s", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
return Decrypt(ciphertext)
|
||||
}
|
||||
Reference in New Issue
Block a user