今天有点冷….风吹吹~~~做公司的论坛DZ模版…

去网上看了一些DZ的模版,,NND,,却是Base64加密…呵呵..有点不爽…不过..还是有方法弄出来的..瞧一瞧..

下面留下方法

Base64转换
新建一个Windows应用程序,一个文本框,两个按钮:
//添加两个CryptoStream,但顺序相反
private void btnWrite_Click(object sender, System.EventArgs e)
{
//open a file for writting to
FileStream fs=new FileStream(“I:\testfile.txt”,FileMode.Create);

//create a stream for converting to base64 encoding
ICryptoTransform transformEncode=new ToBase64Transform();
CryptoStream csEncode=new CryptoStream(fs,transformEncode,CryptoStreamMode.Write);

//create a stream for encryption
ICryptoTransform transformEncrypt=crypt.CreateEncryptor();
CryptoStream csEncrypt=new CryptoStream(csEncode,transformEncrypt,CryptoStreamMode.Write);

//create a text writer
StreamWriter w=new StreamWriter(csEncrypt);
w.Write(this.txtMessage.Text);

w.Flush();
csEncrypt.FlushFinalBlock();

w.Close();
MessageBox.Show(“文件创建成功!”);
}

//将信息转换为原来的形式,然后再JEM
private void btnRead_Click(object sender, System.EventArgs e)
{
//open a file for reading from
FileStream fs=new FileStream(“I:\testfile.txt”,FileMode.Open);

//create a stream for converting from Base64 encoding
ICryptoTransform transformDecode=new FromBase64Transform();
CryptoStream csDecode=new CryptoStream(fs,transformDecode,CryptoStreamMode.Read);

//create a cryptographic stream
ICryptoTransform transformDecrypt=crypt.CreateDecryptor();
CryptoStream csDecrypt=new CryptoStream(csDecode,transformDecrypt,CryptoStreamMode.Read);

//create a text reader
StreamReader r=new StreamReader(csDecrypt);
string text=r.ReadToEnd();
r.Close();

MessageBox.Show(“Retrived:”+text);
this.txtMessage.Text=text;
}

0
如无特殊说明,文章均为本站原创,转载请注明出处

该文章由 发布

这货来去如风,什么鬼都没留下!!!
发表我的评论

Hi,请填写昵称和邮箱!

取消评论
代码 贴图 加粗 链接 删除线 签到