好像有个叫作secret的类,不知道是不是用来加密的,怎么用

解决方案 »

  1.   

    到.net自带的msdn上查一下"加密",出来很多例子啊
      

  2.   

    //加密
    static String encrypt(String data) {
    byte[] bytes = Encoding.Unicode.GetBytes(data);
    byte[] key = {43, 136, 76, 107, 172, 255, 227, 114};
    byte[] iv = {102, 117, 69, 24, 131, 225, 93, 170};
    DESCryptoServiceProvider desc = new DESCryptoServiceProvider();
    ICryptoTransform entrans = desc.CreateEncryptor(key, iv);
    byte[] en = entrans.TransformFinalBlock(bytes, 0, bytes.Length);
    String res = Encoding.Unicode.GetString(en);
    return res;
    }//解密
    static String decrypt(String data) {
    byte[] bytes = Encoding.Unicode.GetBytes(data);
    byte[] key = {43, 136, 76, 107, 172, 255, 227, 114};
    byte[] iv = {102, 117, 69, 24, 131, 225, 93, 170};
    DESCryptoServiceProvider desc = new DESCryptoServiceProvider();
    ICryptoTransform detrans = desc.CreateDecryptor(key, iv);
    byte[] de = detrans.TransformFinalBlock(en, 0, en.Length);
    String res = Encoding.Unicode.GetString(de);
    return res;
    }
      

  3.   

    using System.Text;
    using System.Security.Cryptography;//加密包
      

  4.   

    There are three types of encryption.
    1. Symmetric Encryption, for example, DES, Extended DES. With this method, encryption, and decryption use the same key.
    2. Asymmetric Encryption, i.e. public key encryption. There are public key and private key in this method. If you encrypt data with public key, the decryption process must use private key; if you encrpt data with private key, the decrption must use public key. For example, DSA, RSA, and ECC ( this is relatively a new encryption method, not implemented in .net encryption namespace).
    3. Hash encryption. If you are familiar with Perl, you must know md5.