コード例 #1
0
 public static bool[] HexToBits(string hex)
 {
     bool[] ret;
     byte[] toByte = BitManipulator.FromHex(hex);
     ret = (BitManipulator.GetMasks(toByte)).ToArray();
     return(ret);
 }
コード例 #2
0
        private bool[] Sbox(bool[] sboxCellInput, int[,] sbox)
        {
            bool[] rowInBool = { sboxCellInput[0], sboxCellInput[5] };
            bool[] colInBool = { sboxCellInput[1], sboxCellInput[2], sboxCellInput[3], sboxCellInput[4] };
            byte[] rowInByte = BitManipulator.BoolToByte(rowInBool);
            byte[] colInByte = BitManipulator.BoolToByte(colInBool);
            int    row       = (int)(Convert.ToDecimal(rowInByte[0]));
            int    col       = (int)(Convert.ToDecimal(colInByte[0]));
            int    temp      = sbox[row, col];

            byte[] b = BitManipulator.IntTobytes(temp);
            bool[] sboxCellOutput = new bool[4];
            Array.Copy(BitManipulator.GetMasks(b).ToArray(), 28, sboxCellOutput, 0, 4);
            return(sboxCellOutput);
        }
コード例 #3
0
        private void SetBlocksOfencyptedMessage(char[] encyptedMessage)
        {
            int numOfBlock = encyptedMessage.Length / 8;

            this.blocks = new bool[numOfBlock][];
            byte[] MsgByte = new byte[8];
            for (int i = 0; i < numOfBlock; i++)
            {
                for (int j = 0; j < MsgByte.Length; j++)
                {
                    MsgByte[j] = (byte)encyptedMessage[j + (i * 8)];
                }
                Array.Reverse(MsgByte);
                this.blocks[i] = (BitManipulator.GetMasks(MsgByte)).ToArray();
            }
        }