mirror of
https://github.com/xinliangnote/go-gin-api.git
synced 2024-04-21 12:31:46 +00:00
26 lines
453 B
Go
26 lines
453 B
Go
package aes
|
|
|
|
import "testing"
|
|
|
|
const (
|
|
key = "IgkibX71IEf382PT"
|
|
iv = "IgkibX71IEf382PT"
|
|
)
|
|
|
|
func TestEncrypt(t *testing.T) {
|
|
t.Log(New(key, iv).Encrypt("123456"))
|
|
}
|
|
|
|
func TestDecrypt(t *testing.T) {
|
|
t.Log(New(key, iv).Decrypt("GO-ri84zevE-z1biJwfQPw=="))
|
|
}
|
|
|
|
func BenchmarkEncryptAndDecrypt(b *testing.B) {
|
|
b.ResetTimer()
|
|
aes := New(key, iv)
|
|
for i := 0; i < b.N; i++ {
|
|
encryptString, _ := aes.Encrypt("123456")
|
|
aes.Decrypt(encryptString)
|
|
}
|
|
}
|