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))); }
/// <summary> /// 压缩字节数组 /// </summary> public static byte[] Compress(byte[] bytes, int offset = 0) { using (MemoryStream ms = new MemoryStream()) { SharpZipHelper.Compress(ms, bytes, offset); return(ms.ToArray()); } }
public static string DecompressString(byte[] bytes, Encoding encoding) { if (bytes == null || bytes.Length == 0) { return(string.Empty); } return(encoding.GetString(SharpZipHelper.Decompress(bytes))); }
public static byte[] CompressString(string str, Encoding encoding) { if (string.IsNullOrEmpty(str)) { return(new byte[0]); } return(SharpZipHelper.Compress(encoding.GetBytes(str))); }
public SmartObjectDeserializer(byte[] objBytes) { this.ObjBytes = objBytes; bool isCommpress = this.ReadBool(); if (isCommpress) { this.ObjBytes = SharpZipHelper.Decompress(this.ObjBytes, sizeof(bool)); this.Index = 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()); } }
public static string DecompressString(byte[] bytes) { return(SharpZipHelper.DecompressString(bytes, Encoding.Unicode)); }
public static byte[] CompressString(string str) { return(SharpZipHelper.CompressString(str, Encoding.Unicode)); }
/// <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)); }