Example #1
0
        private static byte q(byte x, byte[,] t)
        {
            int a0 = x / 16;
            int b0 = x % 16;
            int a1 = a0 ^ b0;
            int b1 = a0 ^ Word4Bits.RotateRight((byte)b0) ^ 8 * a0 % 16;
            int a2 = t[0, a1];
            int b2 = t[1, b1];
            int a3 = a2 ^ b2;
            int b3 = a2 ^ Word4Bits.RotateRight((byte)b2) ^ 8 * a2 % 16;
            int a4 = t[2, a3];
            int b4 = t[3, b3];

            return(Convert.ToByte(16 * b4 + a4));
        }
Example #2
0
 public void RotateLeft_RotatesOneBit_Rotated()
 {
     Assert.AreEqual(15, Word4Bits.RotateLeft(15));
     Assert.AreEqual(14, Word4Bits.RotateLeft(7));
 }
Example #3
0
 public void RotateRight_RotatesThreeBits_Rotated()
 {
     Assert.AreEqual(15, Word4Bits.RotateRight(15, 3));
     Assert.AreEqual(7, Word4Bits.RotateRight(11, 3));
 }
Example #4
0
 public void RotateRight_RotatesOneBit_Rotated()
 {
     Assert.AreEqual(15, Word4Bits.RotateRight(15));
     Assert.AreEqual(7, Word4Bits.RotateRight(14));
 }
Example #5
0
 public void RotateLeft_RotatesThreeBits_Rotated()
 {
     Assert.AreEqual(15, Word4Bits.RotateLeft(15, 3));
     Assert.AreEqual(11, Word4Bits.RotateLeft(7, 3));
 }