新增代理实名认证和授权
This commit is contained in:
31
pkg/lzkit/crypto/crypto_test.go
Normal file
31
pkg/lzkit/crypto/crypto_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package crypto
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAesEncryptDecrypt(t *testing.T) {
|
||||
keyHex := "ff83609b2b24fc73196aac3d3dfb874f"
|
||||
key, decodeErr := hex.DecodeString(keyHex)
|
||||
if decodeErr != nil {
|
||||
t.Fatalf("key decode error: %v", decodeErr)
|
||||
}
|
||||
|
||||
plainText := "45212220000827423X"
|
||||
|
||||
cipherText, err := AesEncrypt([]byte(plainText), key)
|
||||
if err != nil {
|
||||
t.Fatalf("AesEncrypt error: %v", err)
|
||||
}
|
||||
fmt.Println(cipherText)
|
||||
decrypted, err := AesDecrypt(cipherText, key)
|
||||
if err != nil {
|
||||
t.Fatalf("AesDecrypt error: %v", err)
|
||||
}
|
||||
|
||||
if string(decrypted) != plainText {
|
||||
t.Errorf("AesDecrypt result not match, got: %s, want: %s", string(decrypted), plainText)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user