package sm2

import (
	"fmt"
	"testing"
)

const (
	SELF_PRI = "EA7CB6F907A96264D6763F8C46AB96B476538D2ABC880A459E10BE5A1C30013D"

	SELF_PUB = "04363DF574D4FE34EE58FB8A3F7CB08E6CA5EBB3B7335CBAE10A2900551F6450AB3AD25DBC0A76EFA9E6D44D2C51E3027483F7BFD09996457888BAFD1AF673817F"
)

func TestGenerateSM2KeyPair(t *testing.T) {
	// Generate a new SM2 key pair
	privateKey, publicKey := GenerateKey()

	// Print the private and public keys
	fmt.Printf("Private Key: %s\n", privateKey)
	fmt.Printf("Public Key: %s", publicKey)
}

func TestSM2Encrypt(t *testing.T) {
	t.Log(encrypt())
}

func TestSM2Decrypt(t *testing.T) {
	en := encrypt()
	decrypt, err := SM2Decrypt(en, SELF_PUB, SELF_PRI)
	if err != nil {
		panic(err)
	}
	t.Log(decrypt)
}

func encrypt() string {
	data := "{\"name\":\"张三\",\"sex\":1,\"is_human\":true}"
	en, err := SM2Encrypt(data, SELF_PUB)
	if err != nil {
		panic(err)
	}
	return en
}