rgbKey对称算法加密 private void button2_Click(object sender, EventArgs e) { string myFile = textBox1.Text; //获取源文件路径 string myPassword = textBox2.Text; //获取加密密码 string myEnFile = textBox3.Text; //获取加密后的文件路径 try { byte[] myIV = { 0x12, 0x34, 0x56, 0x78, 0x90, 0xAB, 0xCD, 0xEF };//设置向量 byte[] myKey = System.Text.Encoding.UTF8.GetBytes(myPassword); //设置密钥 FileStream myInStream = new FileStream(myFile, FileMode.Open, FileAccess.Read); FileStream myOutStream = new FileStream(myEnFile, FileMode.OpenOrCreate, FileAccess.Write); myOutStream.SetLength(0); //初始文件流的长度 byte[] myBytes = new byte[100]; //定义缓冲区 long myInLength = 0; //定义不断变化的流的长度 long myLength = myInStream.Length; //获取源文件的文件流的长度 DES myProvider = new DESCryptoServiceProvider();//定义标准的加密算法实例 //实现将数据流连接到加密转换的流中 CryptoStream myCryptoStream = new CryptoStream(myOutStream, myProvider.CreateEncryptor(myKey, myIV), CryptoStreamMode.Write); //从源文件流中每次读取100个字母,然后写入加密转换流中 while (myInLength < myLength) {//CodeGo.net/ int mylen = myInStream.Read(myBytes, 0, 100);//读取原文件流 myCryptoStream.Write(myBytes, 0, mylen); //写入加密转换的流 myInLength += mylen; //计算写入的流的长度 } myCryptoStream.Close(); //关闭资源 myInStream.Close(); myOutStream.Close(); MessageBox.Show("加密文件成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
加壳吧,混淆是没用的
110,535
社区成员
642,577
社区内容
加载中
让您成为最强悍的C#开发者
试试用AI创作助手写篇文章吧