Пример #1
0
 private void Decrypt_Click(object sender, RoutedEventArgs e)
 {
     var lines = File.ReadAllLines(pathFileTB.Text);
     var close_key = File.ReadAllLines(pathkeyTB.Text);
     var E = new BigInteger(close_key[0].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
     var N = new BigInteger(close_key[1].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
     var cryptArr = new BigInteger[lines.Length];
     for (int i = 0, k = 0; i < lines.Length; i++)
     {
         cryptArr[k++] = RSAEx.DeCrypt(new BigInteger(lines[i].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray()), E, N);
     }
     var bytes = cryptArr.SelectMany(a => a.ToByteArray()).ToArray();
     File.WriteAllBytes(pathFiledecTB.Text, bytes);
     MessageBox.Show("Расшифрование завершено!");
 }
Пример #2
0
        private void DecryptPass(object sender, RoutedEventArgs e)
        {
            var lines     = File.ReadAllLines(pathCodPassTB.Text);
            var close_key = File.ReadAllLines(RecipientPath + @"\close_key.txt");
            var E         = new BigInteger(close_key[0].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
            var N         = new BigInteger(close_key[1].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray());
            var cryptArr  = new BigInteger[lines.Length];

            for (int i = 0, k = 0; i < lines.Length; i++)
            {
                cryptArr[k++] = RSAEx.DeCrypt(new BigInteger(lines[i].Split(' ').Select(a => byte.Parse(a.ToString(), NumberStyles.HexNumber)).ToArray()), E, N);
            }
            var bytes = cryptArr.SelectMany(a => a.ToByteArray()).ToArray();

            File.WriteAllBytes(RecipientPath + @"\pass.txt", bytes);
            encryptMGrid.Visibility = Visibility.Visible;
            ;
        }