比如1345567800696034这么长的一串数字,压缩成字母加数值型的字符串,请问该如何实现?

解决方案 »

  1.   

    md5,des,rsa等加密
    如public string Encrypt(string pToEncrypt, string sKey)
      {
      using (DESCryptoServiceProvider des = new DESCryptoServiceProvider())
      {
      byte[] inputByteArray = Encoding.UTF8.GetBytes(pToEncrypt);
      des.Key = ASCIIEncoding.ASCII.GetBytes(sKey);
      des.IV = ASCIIEncoding.ASCII.GetBytes(sKey);
      System.IO.MemoryStream ms = new System.IO.MemoryStream();
      using (CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write))
      {
      cs.Write(inputByteArray, 0, inputByteArray.Length);
      cs.FlushFinalBlock();
      cs.Close();
      }
      string str = Convert.ToBase64String(ms.ToArray());
      ms.Close();
      return str;
      }
      }
      

  2.   

    可以考虑先用 BigInteger.Parse() 读入,然后转换为 byte[],再转换为 Base64 编码。