Пример #1
0
        private Stack setKeyStack(string keyString)
        {
            key   obj      = new key(keyString);
            Stack keyStack = new Stack();

            for (int counter = 0; counter < 8; counter++)
            {
                keyStack.Push(obj.GetNextKey());
            }

            return(keyStack);
        }
        private BitArray encrypt32bits(String keyString, BitArray bitText32)
        {
            key      obj     = new key(keyString);
            BitArray keyBits = new BitArray(16);

            List <BitArray> list  = BitOperations.splitKBits(bitText32);
            BitArray        right = new BitArray(16);
            BitArray        left  = new BitArray(16);

            for (int i = 0; i < 8; i++)
            {
                keyBits = obj.GetNextKey();
                right   = (BitArray)list[1].Clone();
                //Console.WriteLine("Input 32 bits split into : " + BitOperations.getBinaryString(list[0]) +" and "+ BitOperations.getBinaryString(list[1]));

                left = list[0].Xor(feistelFunction(keyBits, list[1]));
                //Console.WriteLine("left after xoring woth fiestal output : " + BitOperations.getBinaryString(left));
                list[0] = right; list[1] = left;
            }
            return(BitOperations.CombineBitArrays(left, right));
        }
        private BitArray encrypt32bits(String keyString, BitArray bitText32)
        {
            key obj = new key(keyString);
            BitArray keyBits = new BitArray(16);
            
            List<BitArray> list = BitOperations.splitKBits(bitText32);
            BitArray right = new BitArray(16);
            BitArray left = new BitArray(16);

            for (int i = 0; i < 8; i++)
            {
                keyBits = obj.GetNextKey();
                right = (BitArray)list[1].Clone();
                //Console.WriteLine("Input 32 bits split into : " + BitOperations.getBinaryString(list[0]) +" and "+ BitOperations.getBinaryString(list[1]));

                left = list[0].Xor(feistelFunction(keyBits, list[1]));
                //Console.WriteLine("left after xoring woth fiestal output : " + BitOperations.getBinaryString(left));
                list[0] = right; list[1] = left;
            }
            return BitOperations.CombineBitArrays(left, right);
        }
        private Stack setKeyStack(string keyString)
        {
            key obj = new key(keyString);
            Stack keyStack = new Stack();
            for (int counter = 0; counter < 8; counter++)
            {
                keyStack.Push(obj.GetNextKey());
            }

            return keyStack;
        }