✨ encapsulate object storage service operations
This commit is contained in:
26
common/encrypt/aes_test.go
Normal file
26
common/encrypt/aes_test.go
Normal file
@@ -0,0 +1,26 @@
|
||||
package encrypt
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestAES(t *testing.T) {
|
||||
key := "thisisasecretkey" // 16 字节密钥
|
||||
plainText := "Hello, AES-GCM encryption!"
|
||||
|
||||
// 加密
|
||||
encrypted, err := Encrypt(plainText, key)
|
||||
if err != nil {
|
||||
log.Fatalf("加密失败: %v", err)
|
||||
}
|
||||
fmt.Printf("加密结果: %s\n", encrypted)
|
||||
|
||||
// 解密
|
||||
decrypted, err := Decrypt(encrypted, key)
|
||||
if err != nil {
|
||||
log.Fatalf("解密失败: %v", err)
|
||||
}
|
||||
fmt.Printf("解密结果: %s\n", decrypted)
|
||||
}
|
Reference in New Issue
Block a user