You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
901 B
39 lines
901 B
using Tiobon.Core.Common.Helper.SM;
|
|
using Xunit;
|
|
|
|
namespace Tiobon.Core.Tests.Common_Test;
|
|
|
|
public class SM4Helper_Should
|
|
{
|
|
|
|
[Fact]
|
|
public void Encrypt_ECB_Test()
|
|
{
|
|
var plainText = "暗号";
|
|
|
|
var sm4 = new SM4Helper();
|
|
|
|
Console.Out.WriteLine("ECB模式");
|
|
var cipherText = sm4.Encrypt_ECB(plainText);
|
|
Console.Out.WriteLine("密文: " + cipherText);
|
|
|
|
Assert.NotNull(cipherText);
|
|
Assert.Equal("VhVDC0KzyZjAVMpwz0GyQA==", cipherText);
|
|
}
|
|
|
|
[Fact]
|
|
public void Decrypt_ECB_Test()
|
|
{
|
|
var cipherText = "Y9ygWexdpuLQjW/qsnZNQw==";
|
|
|
|
var sm4 = new SM4Helper();
|
|
|
|
Console.Out.WriteLine("ECB模式");
|
|
var plainText = sm4.Decrypt_ECB(cipherText);
|
|
Console.Out.WriteLine("明文: " + plainText);
|
|
|
|
Assert.NotNull(plainText);
|
|
Assert.Equal("老张的哲学", plainText);
|
|
}
|
|
|
|
}
|
|
|