public Tuple<string, string> SaySomethingTo(Actor a) { Random r = new Random(DateTime.Now.Millisecond); string whatISaid = sharedWisdom[r.Next(0, sharedWisdom.Count())]; string theirPublicKey = a.RequestPublicKey(); string howIWillSayIt = new BytestringEncryptor(theirPublicKey).EncryptString(whatISaid); string whatTheyHeard = a.SayItBackToMe(howIWillSayIt, theirPublicKey); return new Tuple<string, string>(whatISaid, whatTheyHeard); }
public void ByteStringEncryptor() { KeyPair kp = new KeyPair(); string publicKey = kp.PublicKey; string textToEncrypt = "Colorless green ideas sleep furiously."; BytestringEncryptor bse = new BytestringEncryptor(publicKey); string encryptedText = bse.EncryptString(textToEncrypt); string decryptedText = kp.DecryptBase64String(encryptedText); Assert.AreEqual(textToEncrypt, decryptedText); }