请问,如何压缩字符串?

RayLynn 2010-11-28 10:54:43
比如1345567800696034

这么长的一串数字,压缩成字母加数值型的字符串,请问该如何实现?
...全文
99 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyi8808 2010-11-28
  • 打赏
  • 举报
回复
可以考虑先用 BigInteger.Parse() 读入,然后转换为 byte[],再转换为 Base64 编码。
兔子-顾问 2010-11-28
  • 打赏
  • 举报
回复
System.IO.Compression.DeflateStream
wuyq11 2010-11-28
  • 打赏
  • 举报
回复
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;
}
}
龍月 2010-11-28
  • 打赏
  • 举报
回复
压缩还是 加密?

110,568

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧