예제 #1
0
        private static string Decrypt(byte[] bytes, int len, Expression exp)
        {
            byte[] ret = new byte[(len + 7) & ~7];

            using (BinaryReader rdr = new BinaryReader(new MemoryStream(bytes)))
            {
                for (int i = 0; i < ret.Length; i++)
                {
                    int r = Read7BitEncodedInt(rdr);
                    ret[i] = (byte)LongExpressionEvaluator.Evaluate(exp, r);
                }
            }

            return(Encoding.Unicode.GetString(ret, 0, len));
        }
예제 #2
0
        private static byte[] Encrypt(byte[] bytes, Expression exp, out int len)
        {
            byte[] tmp = new byte[(bytes.Length + 7) & ~7];
            Buffer.BlockCopy(bytes, 0, tmp, 0, bytes.Length);
            len = bytes.Length;

            MemoryStream ret = new MemoryStream();

            using (BinaryWriter wtr = new BinaryWriter(ret))
            {
                for (int i = 0; i < tmp.Length; i++)
                {
                    int en = (int)LongExpressionEvaluator.Evaluate(exp, tmp[i]);
                    Write7BitEncodedInt(wtr, en);
                }
            }

            return(ret.ToArray());
        }