ecb_test.go 780 B

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package util
  4. import (
  5. "encoding/base64"
  6. "testing"
  7. )
  8. func Test_AesEncryt(t *testing.T) {
  9. if data, err := AesEncrypt("abc", "08d77a89db24d8a6271f488462b500ce"); err == nil {
  10. baseData := base64.StdEncoding.EncodeToString(data)
  11. t.Log(baseData)
  12. } else {
  13. t.Error(err)
  14. }
  15. }
  16. func Test_AesDecryt(t *testing.T) {
  17. if src, err := base64.StdEncoding.DecodeString("RDlKksejWobcc/2V8XBVHQ=="); err == nil {
  18. if data, err := AesDecrypt(src, []byte("08d77a89db24d8a6271f488462b500ce")); err == nil {
  19. t.Log(string(data))
  20. if string(data) != "abc" {
  21. t.Errorf("AesDecrypt failed. data:%s", string(data))
  22. }
  23. } else {
  24. t.Error(err)
  25. }
  26. } else {
  27. t.Error(err)
  28. }
  29. }