Пример #1
0
        public static byte[] Encrypt(byte[] input, uint ms)
        {
            var ct = new CipherText(input, ms);
            var iv = Cipher8FromRand(ref ms);

            //encrypt
            foreach (var bytes in ct.Content)
            {
                for (var j = 0; j < 256; j++)
                {
                    bytes[j] ^= iv[j];
                }

                var temp2 = new uint[0x100 / 4];
                Buffer.BlockCopy(bytes, 0, temp2, 0, 0x100);
                Shuffles.Shuffle2(temp2);

                Buffer.BlockCopy(temp2, 0, iv, 0, 0x100);
                Buffer.BlockCopy(temp2, 0, bytes, 0, 0x100);
            }

            return(ct.GetBytes(ref ms));
        }
Пример #2
0
        //private static byte makeIntegrityByte(byte rand)
        //{
        //    char lastbyte = rand->rand();
        //    char tmp = lastbyte & 0xf3;
        //    return ((~tmp & 0x67) | (tmp & 0x98)) ^ 0x77 | (tmp & 0x10);
        //}

        public byte[] Encrypt(byte[] input, uint ms)
        {
            CipherText ct = new CipherText(input, ms);

            byte[] iv = cipher8_from_rand(ref ms);

            //encrypt
            for (int i = 0; i < ct.content.Count; i++)
            {
                for (int j = 0; j < 256; j++)
                {
                    ct.content[i][j] ^= iv[j];
                }

                uint[] temp2 = new uint[0x100 / 4];
                Buffer.BlockCopy(ct.content[i], 0, temp2, 0, 0x100);
                Shuffles.Shuffle2(temp2);

                Buffer.BlockCopy(temp2, 0, iv, 0, 0x100);
                Buffer.BlockCopy(temp2, 0, ct.content[i], 0, 0x100);
            }

            return(ct.getBytes(ref ms));
        }