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