Hi

 

The TNX family on NuGet grows with a new easy-to-use helper assembly about cryptography

According to NuGet description, TNX.Cryprography bring the following extension methods available to anyone by System namespace, without the need of the “using” keyword
+ ToCryptoStringDES
+ FromCryptoStringDES
+ ToCryptoString3DES
+ FromCryptoString3DES
+ ToCryptoStringAES
+ FromCryptoStringAES
+ ToCryptoStringRSA
+ ToCryptoArrayRSA
+ GetRandomRSAKey
+ GetPublicRsaKeyFromXmlString
+ FromCryptoStringRSA

 

 

Here some unit test from my project

 

[TestMethod]
public void DesTest1()
{
var k = “12345678”;
var i = “12345678”;
var text = “bla bla bla”;
var crypto = text.ToCryptoStringDES(k, i);
var again = crypto.FromCryptoStringDES(k, i);
Assert.AreEqual(text, again);
}

[TestMethod]
public void TriDesTest1()
{
var k = “1234567890123456”;
var i = “12345678”;
var text = “bla bla bla”;
var crypto = text.ToCryptoString3DES(k, i);
var again = crypto.FromCryptoString3DES(k, i);
Assert.AreEqual(text, again);
}

[TestMethod]
public void AesTest1()
{
var k = “1234567890123456”;
var i = “1234567890123456”;
var text = “bla bla bla”;
var crypto = text.ToCryptoStringAES(k, i);
var again = crypto.FromCryptoStringAES(k, i);
Assert.AreEqual(text, again);
}

[TestMethod]
public void RsaTest1()
{
var text = “bla bla bla”;
var k = CryptoHelper.GetRandomRSAKey();
var p = k.GetPublicRsaKeyFromXmlString();
var crypto = text.ToCryptoStringRSA(p);
var again = crypto.FromCryptoStringRSA(k);
Assert.AreEqual(text, again);
}

 

as always, any question here: info@antonioesposito.it

 

Lascia un commento