public void StringCrypt_Basic_RSA() { string input = "test 123 %$#"; byte[] output = StringCrypt.EncryptRSA(input); string outputFinal = StringCrypt.DecryptRSA(output); Assert.AreEqual(input, outputFinal, "String output should be as exected after decrypt."); }
public void StringCrypt_Specific_RSA_KeySize() { string input = "foobar and some special characters $%^&*()"; RSACryptInfo cryptInfo = new RSACryptInfo(1024); byte[] output = StringCrypt.EncryptRSA(input, cryptInfo); string outputFinal = StringCrypt.DecryptRSA(output, cryptInfo); Assert.AreEqual(input, outputFinal, "String output should be as exected after decrypt."); }
public void StringCrypt_Specific_RSA_WrongPrivatKey() { string input = "foobar and some special characters $%^&*()"; RSACryptInfo cryptInfo1 = new RSACryptInfo(512); RSACryptInfo cryptInfo2 = new RSACryptInfo(512); RSACryptInfo cryptInfoKey = new RSACryptInfo(512); cryptInfo2.privateKey = cryptInfoKey.privateKey; byte[] output = StringCrypt.EncryptRSA(input, cryptInfo1); string outputFinal = StringCrypt.DecryptRSA(output, cryptInfo2); Assert.AreNotEqual(input, outputFinal, "String output should not be decryptable."); }
public void StringCrypt_Specific_RSA_CustomKeys() { string input = "foobar and some special characters $%^&*()"; RSACryptInfo cryptInfo = new RSACryptInfo(512); RSACryptInfo cryptInfoKey = new RSACryptInfo(512); cryptInfo.publicKey = cryptInfoKey.publicKey; cryptInfo.privateKey = cryptInfoKey.privateKey; byte[] output = StringCrypt.EncryptRSA(input, cryptInfo); string outputFinal = StringCrypt.DecryptRSA(output, cryptInfo); Assert.AreEqual(input, outputFinal, "String output should be as exected after decrypt."); }