package encryption_decryption_test import ( "fusenapi/utils/auth" "fusenapi/utils/encryption_decryption" "log" "testing" ) func TestGCM(t *testing.T) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", Wid: "123", } key := "fusen123321" gcm := encryption_decryption.NewSecretGCM[auth.RegisterToken](key) tstr, err := gcm.Encrypt(token) if err != nil { t.Error(err) } log.Println(tstr) log.Println(gcm.Decrypt(tstr)) } func BenchmarkCRT(b *testing.B) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", Wid: "123", } key := "fusen123321" iv := "1234567890123456" for i := 0; i < b.N; i++ { crt := encryption_decryption.NewSecretCRT[auth.RegisterToken](key, iv) tstr, err := crt.Encrypt(token) if err != nil { b.Error(err) } crt.Decrypt(tstr) } } func BenchmarkGCM(b *testing.B) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", Wid: "123", } key := "fusen123321" for i := 0; i < b.N; i++ { crt := encryption_decryption.NewSecretGCM[auth.RegisterToken](key) tstr, err := crt.Encrypt(token) if err != nil { b.Error(err) } crt.Decrypt(tstr) } } func TestCRT(t *testing.T) { token := &auth.RegisterToken{ OperateType: auth.OpTypeRegister, Password: "fusen_password", Wid: "123", } key := "fusen123321" iv := "1234567890123456" crt := encryption_decryption.NewSecretCRT[auth.RegisterToken](key, iv) tstr, err := crt.Encrypt(token) if err != nil { t.Error(err) } log.Println(tstr) log.Println(crt.Decrypt(tstr)) }