本文介绍了我的代码有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用执行模块化算术的函数(modexp)加密文件.但是我没有一种正确的方法来逐字符读取char,然后对该char执行一些算术(modexp),然后将加密的聊天记录写入新文件.
我已经写了这样的代码.

I''m trying to encrypt a file with a function(modexp) which does modular arithmetic. but I''m nor getting a proper way to read char by char and then do some arithmetic(modexp) on that char, then encrypted chat should be written to a new file.
I have written my code like this.

private void btnSubmit_Click(object sender, EventArgs e)
{

        FileStream fr = new FileStream(textBox6.Text, FileMode.Open, FileAccess.Read);
        try
        {
            MessageBox.Show("Encryption Started");
            FileStream fw = new FileStream(textBox7.Text, FileMode.Create, FileAccess.Write);
            byte[] buffer = new byte[1];
            while (fr.Position != fr.Length)
            {
                int m = fr.Read(buffer, 0, buffer.Length);
               string m1 = modexp(m.ToString().Trim(), textBox4.Text.Trim(), textBox3.Text.Trim());
               fw.Write(buffer, 0, Convert.ToInt32(m1));

            }
            fw.Flush();
            fr.Close();
            fw.Close();
            MessageBox.Show("Encryption Completed");

        }
        catch(Exception ex)
        {
            MessageBox.Show("File creation Error" + ex, "Implementation of RSA");
        }

  }


请帮帮我.

提前谢谢.
Ganesh.


Please help me.

Thanks in advance.
Ganesh.

推荐答案


这篇关于我的代码有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 19:58
查看更多