Example #1
0
 /// <summary>
 /// 将传入Base64Str以GZip算法解压缩
 /// </summary>
 /// <param name="zippedString">经GZip压缩后的Base64Str</param>
 /// <returns>原始byte[]</returns>
 public static byte[] Decompress2ByteArr(string zippedString)
 {
     if (zippedString.IsNullOrWhiteSpace() == true)
     {
         return(null);
     }
     else
     {
         byte[] zippedByteArr = Convert.FromBase64String(zippedString.ToString());
         return(GZipUtils.Decompress(zippedByteArr));
     }
 }
Example #2
0
 /// <summary>
 /// 将传入字符串以GZip算法压缩后,返回byte[]
 /// </summary>
 /// <param name="toZipString">需要压缩的字符串</param>
 /// <returns>压缩后的byte[]</returns>
 public static byte[] Compress2ByteArr(string toZipString)
 {
     if (toZipString.IsNullOrWhiteSpace() == true)
     {
         return(null);
     }
     else
     {
         byte[] toZipByteArr = System.Text.Encoding.UTF8.GetBytes(toZipString);
         return(GZipUtils.Compress(toZipByteArr));
     }
 }
Example #3
0
 /// <summary>
 /// 将传入字符串以GZip算法压缩后,返回Base64Str
 /// </summary>
 /// <param name="toZipString">需要压缩的字符串</param>
 /// <returns>压缩后的Base64Str</returns>
 public static string Compress2String(string toZipString)
 {
     if (toZipString.IsNullOrWhiteSpace() == true)
     {
         return(string.Empty);
     }
     else
     {
         byte[] toZipByteArr  = System.Text.Encoding.UTF8.GetBytes(toZipString);
         byte[] zippedByteArr = GZipUtils.Compress(toZipByteArr);
         return(Convert.ToBase64String(zippedByteArr));
     }
 }
Example #4
0
 /// <summary>
 /// 将传入Base64Str以GZip算法解压缩
 /// </summary>
 /// <param name="zippedString">经GZip压缩后的Base64Str</param>
 /// <returns>原始字符串</returns>
 public static string Decompress2String(string zippedString)
 {
     if (zippedString.IsNullOrWhiteSpace() == true)
     {
         return(string.Empty);
     }
     else
     {
         byte[] zippedByteArr   = Convert.FromBase64String(zippedString.ToString());
         byte[] originalByteArr = GZipUtils.Decompress(zippedByteArr);
         return(System.Text.Encoding.UTF8.GetString(originalByteArr));
     }
 }