示例#1
0
        protected override byte[] GetValidateErrInfo(byte[] headBytes)
        {
            int    currentKey = BitConverter.ToInt32(headBytes, 0);
            string errRtf     = CodySecurity_1.ValidateErrRtf.Replace("【CustomerKey】", currentKey.ToString());

            return(SharpZipHelper.Compress(Encoding.UTF8.GetBytes(errRtf)));
        }
示例#2
0
 /// <summary>
 /// 压缩字节数组
 /// </summary>
 public static byte[] Compress(byte[] bytes, int offset = 0)
 {
     using (MemoryStream ms = new MemoryStream())
     {
         SharpZipHelper.Compress(ms, bytes, offset);
         return(ms.ToArray());
     }
 }
示例#3
0
        public static string DecompressString(byte[] bytes, Encoding encoding)
        {
            if (bytes == null || bytes.Length == 0)
            {
                return(string.Empty);
            }

            return(encoding.GetString(SharpZipHelper.Decompress(bytes)));
        }
示例#4
0
        public static byte[] CompressString(string str, Encoding encoding)
        {
            if (string.IsNullOrEmpty(str))
            {
                return(new byte[0]);
            }

            return(SharpZipHelper.Compress(encoding.GetBytes(str)));
        }
示例#5
0
        public SmartObjectDeserializer(byte[] objBytes)
        {
            this.ObjBytes = objBytes;

            bool isCommpress = this.ReadBool();

            if (isCommpress)
            {
                this.ObjBytes = SharpZipHelper.Decompress(this.ObjBytes, sizeof(bool));
                this.Index    = 0;
            }
        }
示例#6
0
        /// <summary>
        /// 压缩字节数组
        /// </summary>
        public static void Compress(string desFilePath, string tagetFilePath)
        {
            byte[] bytes = File.ReadAllBytes(desFilePath);

            if (File.Exists(tagetFilePath))
            {
                throw new Exception("目标文件已存在!");
            }

            using (FileStream fs = File.Create(tagetFilePath))
            {
                SharpZipHelper.Compress(fs, bytes, 0);
            }
        }
 public byte[] GetBinary()
 {
     if (this.IsCompress)
     {
         using (MemoryStream ms = new MemoryStream())
         {
             ms.Write(BitConverter.GetBytes(this.IsCompress), 0, sizeof(bool));
             byte[] compressBytes = SharpZipHelper.Compress(this.ContextStream.ToArray(), sizeof(bool));
             ms.Write(compressBytes, 0, compressBytes.Length);
             return(ms.ToArray());
         }
     }
     else
     {
         this.Write(this.IsCompress);
         return(this.ContextStream.ToArray());
     }
 }
示例#8
0
 public static string DecompressString(byte[] bytes)
 {
     return(SharpZipHelper.DecompressString(bytes, Encoding.Unicode));
 }
示例#9
0
 public static byte[] CompressString(string str)
 {
     return(SharpZipHelper.CompressString(str, Encoding.Unicode));
 }
示例#10
0
 /// <summary>
 /// 解压缩字节数组
 /// </summary>
 public static byte[] Decompress(byte[] bytes, int offset = 0)
 {
     return(SharpZipHelper.Decompress(bytes, offset, bytes.Length - offset));
 }
 public static byte[] DecryptAndDecompress(byte[] bytes, int key)
 {
     return(SharpZipHelper.Decompress(CodySecurityHelper.Decrypt(bytes, key)));
 }
 public static byte[] CompressAndEncrypt(byte[] bytes, int key)
 {
     return(CodySecurityHelper.Encrypt(SharpZipHelper.Compress(bytes), key));
 }