ecb_test.go 676 B

123456789101112131415161718192021222324252627282930
  1. package config
  2. import (
  3. "encoding/base64"
  4. "testing"
  5. )
  6. func Test_AesEncryt(t *testing.T) {
  7. if data, err := AesEncrypt("abc", "08d77a89db24d8a6271f488462b500ce"); err == nil {
  8. baseData := base64.StdEncoding.EncodeToString(data)
  9. t.Log(baseData)
  10. } else {
  11. t.Error(err)
  12. }
  13. }
  14. func Test_AesDecryt(t *testing.T) {
  15. if src, err := base64.StdEncoding.DecodeString("RDlKksejWobcc/2V8XBVHQ=="); err == nil {
  16. if data, err := AesDecrypt(src, []byte("08d77a89db24d8a6271f488462b500ce")); err == nil {
  17. t.Log(string(data))
  18. if string(data) != "abc" {
  19. t.Errorf("AesDecrypt failed. data:%s", string(data))
  20. }
  21. } else {
  22. t.Error(err)
  23. }
  24. } else {
  25. t.Error(err)
  26. }
  27. }