public IHttpActionResult Send(string message)
        {
            if (string.IsNullOrEmpty(message))
            {
                return(BadRequest("Message must not be null"));
            }
            var decryptedMessageInNumbers = Algorithms.RSADecrypt(BigInteger.Parse(PrivateKey), BigInteger.Parse(Modulus), BigInteger.Parse(message));
            var decryptedMessageInWords   = StringHelpers.DecryptToWords(decryptedMessageInNumbers.ToString());
            var dbManager = new DatabaseManager();

            dbManager.AddMessage(message, decryptedMessageInWords, PrivateKey, PublicKey, Modulus);
            return(Ok("I added your message to DB"));
        }
Example #2
0
        public void InsertMessageTest()
        {
            var dbManager = new DatabaseManager();

            dbManager.AddMessage("a", "a", "34523452345", "123123123", "123123123");
            SqlConnection sqlConnection1 = new SqlConnection(@"Data Source=(LocalDB)\MSSQLLocalDB;AttachDbFilename=C:\Users\Farrukh\Algorithms\Algorithms\Data\DB.mdf;Integrated Security=True");
            SqlCommand    cmd            = new SqlCommand();
            SqlDataReader reader;

            cmd.CommandText = "SELECT * FROM tbl_message";
            cmd.CommandType = CommandType.Text;
            cmd.Connection  = sqlConnection1;

            sqlConnection1.Open();

            reader = cmd.ExecuteReader();
            // Data is accessible through the DataReader object here.
            Console.WriteLine(reader.FieldCount);
            sqlConnection1.Close();
        }