package crypto

import (
	"encoding/hex"
	"fmt"
	"testing"
)

func TestAesEncryptDecrypt(t *testing.T) {
	keyHex := "ff83609b2b24fc73196aac3d3dfb874f"
	key, decodeErr := hex.DecodeString(keyHex)
	if decodeErr != nil {
		t.Fatalf("key decode error: %v", decodeErr)
	}

	plainText := "45212220000827423X"

	cipherText, err := AesEncrypt([]byte(plainText), key)
	if err != nil {
		t.Fatalf("AesEncrypt error: %v", err)
	}
	fmt.Println(cipherText)
	decrypted, err := AesDecrypt(cipherText, key)
	if err != nil {
		t.Fatalf("AesDecrypt error: %v", err)
	}

	if string(decrypted) != plainText {
		t.Errorf("AesDecrypt result not match, got: %s, want: %s", string(decrypted), plainText)
	}
}
