Esempio n. 1
0
        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.");
        }
Esempio n. 2
0
        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.");
        }
Esempio n. 3
0
        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.");
        }