最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
RC2加密算法在C#的应用----完善版
时间:2022-07-02 11:07:14 编辑:袖梨 来源:一聚教程网
using System;
using System.Security.Cryptography;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace Curllion
{
public class Crypt
{
private byte[] key;
private byte[] iv;
private System.Text.ASCIIEncoding asciiEncoding;
private System.Text.UnicodeEncoding textConverter;
private RC2CryptoServiceProvider rc2CSP;
public Crypt()
{
InitializeComponent();
}
private void InitializeComponent()
{
key = new byte[]{106,51,25,141,157,142,23,111,234,159,187,154,215,34,37,204};
iv = new byte[]{135,186,133,136,184,149,153,144};
asciiEncoding = new System.Text.ASCIIEncoding();
textConverter = new System.Text.UnicodeEncoding();
rc2CSP = new RC2CryptoServiceProvider();
}
///
/// 新建一个大小为10261B的文件,以便将加密数据写入固定大小的文件。
///
/// 文件保存的地址,包含文件名
public void InitBinFile(string filePath)
{
byte[] tmp = new byte[10261];
try //创建文件流,将其内容全部写入0
{
System.IO.FileStream writeFileStream = new FileStream(filePath,
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.None,512,false);
for(int i = 0 ;i< 10261;i++)
tmp[i] = 0;
writeFileStream.Write(tmp,0,10261);
writeFileStream.Flush();
writeFileStream.Close();
}
using System.Security.Cryptography;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace Curllion
{
public class Crypt
{
private byte[] key;
private byte[] iv;
private System.Text.ASCIIEncoding asciiEncoding;
private System.Text.UnicodeEncoding textConverter;
private RC2CryptoServiceProvider rc2CSP;
public Crypt()
{
InitializeComponent();
}
private void InitializeComponent()
{
key = new byte[]{106,51,25,141,157,142,23,111,234,159,187,154,215,34,37,204};
iv = new byte[]{135,186,133,136,184,149,153,144};
asciiEncoding = new System.Text.ASCIIEncoding();
textConverter = new System.Text.UnicodeEncoding();
rc2CSP = new RC2CryptoServiceProvider();
}
///
/// 新建一个大小为10261B的文件,以便将加密数据写入固定大小的文件。
///
/// 文件保存的地址,包含文件名
public void InitBinFile(string filePath)
{
byte[] tmp = new byte[10261];
try //创建文件流,将其内容全部写入0
{
System.IO.FileStream writeFileStream = new FileStream(filePath,
System.IO.FileMode.Create,
System.IO.FileAccess.Write,
System.IO.FileShare.None,512,false);
for(int i = 0 ;i< 10261;i++)
tmp[i] = 0;
writeFileStream.Write(tmp,0,10261);
writeFileStream.Flush();
writeFileStream.Close();
}
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21