//Testing class encryption in RSA. public bool ClassEncryption() { KeyPair test = RSA.GenerateKeyPair(64); var dummy = new DummyClass(); //Test variable for integrity check. dummy.dummy = 1; LockedBytes encryptedDummy = RSA.EncryptClass(dummy, test.public_); var newdummy = RSA.DecryptClass <DummyClass>(encryptedDummy, test.private_); if (newdummy.dummy == dummy.dummy) { return(true); } else { return(false); } }
//Testing the locked bytes class. public bool LockedBytesReliability() { KeyPair test = RSA.GenerateKeyPair(64); byte[] b = new byte[1024]; var random = new Random(Environment.TickCount); random.NextBytes(b); LockedBytes locked = new LockedBytes(b, test.public_); byte[] unlocked = locked.DecryptBytes(test.private_); if (b.SequenceEqual(unlocked)) { return(true); } else { return(false); } }