public void Smoke() { string result; using (IPkiCryptographyService srv = new RsaCryptographyService()) { result = srv.Encrypt(_forEncryption, PlainText); } string decryptedText; using (IPkiCryptographyService srv2 = new RsaCryptographyService()) { decryptedText = srv2.Decrypt(_forDecryption, result); } Assert.AreEqual(PlainText, decryptedText); }
public void Bob() { var aliceKeyPair = new PublicKeyGenerator().MakeKeyPair(); var bobKeyPair = new PublicKeyGenerator().MakeKeyPair(); var crypto = new RsaCryptographyService(); var message = "ch"; //message from bob to alice - encrypt with alice public key - sign with bob's private key var keyPair = new KeyPair(aliceKeyPair.Public, bobKeyPair.Private); var cipherText = crypto.SignAndEncrypt(keyPair, message); Console.WriteLine(cipherText); //message received - decrypt with alice private - verify with bob's public key var k2 = new KeyPair(bobKeyPair.Public, aliceKeyPair.Private); var clear = crypto.DecryptAndAuthenticate(k2, cipherText); Console.WriteLine(clear); }