---
title: "c#加密 可逆与不可逆MD5 加密"
author: "fastwind"
date: "2008-05-13T11:57:03Z"
tags: []
slug: "c-md5"
draft: false
lastmod: "2008-05-13T11:57:03Z"
id: 192535
url: "https://fastwind.iteye.com/blog/192535"
---

1、方法一 (不可逆加密) [srxljl](http://hi.baidu.com/srxljl)

 

 

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)public string EncryptPassword(string PasswordString,string PasswordFormat )  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)   ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)   string        encryptPassword = null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)   if (PasswordFormat="SHA1")...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)         encryptPassword=FormsAuthortication.HashPasswordForStoringInConfigFile(PasswordString ,"SHA1");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)         }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)         elseif (PasswordFormat="MD5")  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)   ...{ encryptPassword=FormsAuthortication.HashPasswordForStoringInConfigFile(PasswordString ,"MD5");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)         }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)return encryptPassword ;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}

 

2、方法二 (可逆加密)[srxljl](http://hi.baidu.com/srxljl)

 

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)    public interface IBindesh  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)    string encode(string str);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)    string decode(string str);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)}  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)public class EncryptionDecryption : IBindesh  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)    ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        public string encode(string str)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)        ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            string htext = "";  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            for ( int i = 0; i &lt; str.Length; i++)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)            ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                      htext = htext + (char) (str\[i] + 10 - 1 * 2);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)                  }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            return htext;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)              }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        public string decode(string str)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)        ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            string dtext = "";  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            for ( int i=0; i &lt; str.Length; i++)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)            ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                      dtext = dtext + (char) (str\[i] - 10 + 1\*2);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)                  }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            return dtext;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)              }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)

 

3、方法三 (可逆加密)[srxljl](http://hi.baidu.com/srxljl)

 

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)          
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)        const string KEY\_64 = "VavicApp";//注意了，是8个字符，64位  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)        const string IV\_64 = "VavicApp";  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)public string Encode(string data)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)        ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            byte\[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(KEY\_64);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            byte\[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(IV\_64);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            int i = cryptoProvider.KeySize;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  MemoryStream ms = new MemoryStream();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateEncryptor(byKey, byIV), CryptoStreamMode.Write);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  StreamWriter sw = new StreamWriter(cst);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  sw.Write(data);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  sw.Flush();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  cst.FlushFinalBlock();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  sw.Flush();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            return Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)              }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)        public string Decode(string data)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)        ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            byte\[] byKey = System.Text.ASCIIEncoding.ASCII.GetBytes(KEY\_64);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            byte\[] byIV = System.Text.ASCIIEncoding.ASCII.GetBytes(IV\_64);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            byte\[] byEnc;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            try  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)            ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                      byEnc = Convert.FromBase64String(data);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)                  }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            catch  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)            ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                return null;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)                  }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  DESCryptoServiceProvider cryptoProvider = new DESCryptoServiceProvider();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  MemoryStream ms = new MemoryStream(byEnc);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  CryptoStream cst = new CryptoStream(ms, cryptoProvider.CreateDecryptor(byKey, byIV), CryptoStreamMode.Read);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                  StreamReader sr = new StreamReader(cst);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)            return sr.ReadToEnd();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)              }

 

4,md5(32位加密) [srxljl](http://hi.baidu.com/srxljl)

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)public string GetMD5(string s, string \_input\_charset)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)    ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)        /\*\*//// &lt;summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        /// 与ASP兼容的MD5加密算法  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)        /// &lt;/summary&gt;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             MD5 md5 = new MD5CryptoServiceProvider();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        byte\[] t = md5.ComputeHash(Encoding.GetEncoding(\_input\_charset).GetBytes(s));  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             StringBuilder sb = new StringBuilder(32);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        for (int i = 0; i &lt; t.Length; i++)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)        ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                 sb.Append(t\[i].ToString("x").PadLeft(2, '0'));  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)             }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        return sb.ToString();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)         }

        (16位加密)[srxljl](http://hi.baidu.com/srxljl)

 

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)public static string GetMd5Str(string ConvertString)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)    ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        string t2 = BitConverter.ToString(md5.ComputeHash(UTF8Encoding.Default.GetBytes(ConvertString)), 4, 8);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             t2 = t2.Replace("-", "");  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        return t2;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)         }

 

5、加解文本文件[srxljl](http://hi.baidu.com/srxljl)

 

![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)    //加密文件  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)    private static void EncryptData(String inName, String outName, byte\[] desKey, byte\[] desIV)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)    ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        //Create the file streams to handle the input and output files.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             fout.SetLength(0);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        //Create variables to help with read and write.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        byte\[] bin = new byte\[100]; //This is intermediate storage for the encryption.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        long rdlen = 0;              //This is the total number of bytes written.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        long totlen = fin.Length;    //This is the total length of the input file.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        int len;                     //This is the number of bytes to be written at a time.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             DES des = new DESCryptoServiceProvider();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             CryptoStream encStream = new CryptoStream(fout, des.CreateEncryptor(desKey, desIV), CryptoStreamMode.Write);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        //Read from the input file, then encrypt and write to the output file.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        while (rdlen &lt; totlen)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)        ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                 len = fin.Read(bin, 0, 100);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                 encStream.Write(bin, 0, len);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                 rdlen = rdlen + len;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)             }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             encStream.Close();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             fout.Close();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             fin.Close();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)         }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)    //解密文件  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif)    private static void DecryptData(String inName, String outName, byte\[] desKey, byte\[] desIV)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif)    ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        //Create the file streams to handle the input and output files.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             FileStream fin = new FileStream(inName, FileMode.Open, FileAccess.Read);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             FileStream fout = new FileStream(outName, FileMode.OpenOrCreate, FileAccess.Write);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             fout.SetLength(0);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        //Create variables to help with read and write.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        byte\[] bin = new byte\[100]; //This is intermediate storage for the encryption.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        long rdlen = 0;              //This is the total number of bytes written.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        long totlen = fin.Length;    //This is the total length of the input file.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        int len;                     //This is the number of bytes to be written at a time.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             DES des = new DESCryptoServiceProvider();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             CryptoStream encStream = new CryptoStream(fout, des.CreateDecryptor(desKey, desIV), CryptoStreamMode.Write);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        //Read from the input file, then encrypt and write to the output file.  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)        while (rdlen &lt; totlen)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif)![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif)        ...{  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                 len = fin.Read(bin, 0, 100);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                 encStream.Write(bin, 0, len);  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)                 rdlen = rdlen + len;  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif)             }  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             encStream.Close();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             fout.Close();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif)             fin.Close();  
![](http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif)         }