public static byte[] StringToBytes(string str, int key)
        {
            if (str == null)
            {
                return(new byte[0]);
            }

            return(CodySecurityHelper.CompressAndEncrypt(Encoding.UTF8.GetBytes(str), key));
        }
        public static string BytesToString(byte[] bytes, int key)
        {
            if (bytes == null || bytes.Length == 0)
            {
                return(string.Empty);
            }

            var newbytes = CodySecurityHelper.DecryptAndDecompress(bytes, key);

            if (newbytes == null)
            {
                return(string.Empty);
            }
            else
            {
                return(Encoding.UTF8.GetString(newbytes, 0, newbytes.Length));
            }
        }
 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));
 }