示例#1
0
        public string Decrypt(string cipherText)
        {
            char[] cipherArray     = cipherText.ToCharArray();
            int    i               = 0;
            string decryptedCipher = "";

            progressBar2.Maximum = cipherArray.Length;
            try
            {
                for (; i < cipherArray.Length; i++)
                {
                    Application.DoEvents();
                    string cipher = "";
                    progressBar2.Value = i;
                    int j;
                    for (j = i; cipherArray[j] != '-'; j++)
                    {
                        cipher += cipherArray[j];
                    }

                    i = j;

                    ulong cipherValue = Convert.ToUInt64(cipher);
                    decryptedCipher += ((char)RSAlgorithm.BigMod(cipherValue, d, n)).ToString();
                }
            }
            catch (Exception) { }
            return(decryptedCipher);
        }
示例#2
0
        public string Encrypt(string image, ProgressBar progressBar)
        {
            string hexImage = image;

            char[] hexImageArray = hexImage.ToCharArray();
            string cipher        = "";

            progressBar.Maximum = hexImageArray.Length;
            for (int i = 0; i < hexImageArray.Length; i++)
            {
                Application.DoEvents();
                progressBar.Value = i;
                //lblPercentage.Text = ((double)i / (double)progressBar.Maximum * 100).ToString();

                int percent = (int)(((double)progressBar.Value / (double)progressBar.Maximum) * 100);
                ///progressBar.Refresh();
                progressBar.CreateGraphics().DrawString(percent.ToString() + "%",
                                                        new Font("Arial", (float)8.25, FontStyle.Regular),
                                                        Brushes.Black,
                                                        new PointF(progressBar.Width / 2 - 10, progressBar.Height / 2 - 7));

                if (cipher == "")
                {
                    cipher += RSAlgorithm.BigMod(hexImageArray[i], e, n);
                }
                else
                {
                    cipher += "-" + RSAlgorithm.BigMod(hexImageArray[i], e, n);
                }
            }
            return(cipher);
        }
示例#3
0
        public string Encrypt(string image)
        {
            string hexImage = image;

            char[] hexImageArray = hexImage.ToCharArray();
            string cipher        = "";

            progressBar1.Maximum = hexImageArray.Length;
            for (int i = 0; i < hexImageArray.Length; i++)
            {
                Application.DoEvents();
                progressBar1.Value = i;
                if (cipher == "")
                {
                    cipher += RSAlgorithm.BigMod(hexImageArray[i], e, n);
                }
                else
                {
                    cipher += "-" + RSAlgorithm.BigMod(hexImageArray[i], e, n);
                }
            }
            return(cipher);
        }