aes_test.go 445 B

1234567891011121314151617181920212223
  1. package aes
  2. import (
  3. "fmt"
  4. "testing"
  5. )
  6. func TestAes(t *testing.T) {
  7. key := []byte("1111111111111111")
  8. var origin string = "this is plant text"
  9. ciphertext, err := CBCEncrypt([]byte(origin), key, PKCS5)
  10. if err != nil {
  11. t.Error(err)
  12. }
  13. fmt.Printf("ciphertext:%s\n", ciphertext)
  14. planttext, err := CBCDecrypt(ciphertext, key, PKCS5)
  15. fmt.Printf("planttext: %s\n", planttext)
  16. if string(origin) != string(planttext) {
  17. t.FailNow()
  18. }
  19. }