【www.gdgbn.com--中文酷站】

C#
-----------------------------------------------
//名称空间    
using    System;    
using    System.Security.Cryptography;    
using    System.IO;    
using    System.Text;    

//方法    
//加密方法    
public    string    Encrypt(string    pToEncrypt,    string    sKey)    
{    
        DESCryptoServiceProvider    des    =    new    DESCryptoServiceProvider();    
        //把字符串放到byte数组中    
            //原来使用的UTF8编码,我改成Unicode编码了,不行    
        byte[]    inputByteArray    =    Encoding.Default.GetBytes(pToEncrypt);    
        //byte[]    inputByteArray=Encoding.Unicode.GetBytes(pToEncrypt);    

        //建立加密对象的密钥和偏移量    

本文来源:http://www.gdgbn.com/kuzhan/5064/