private BitArray decrypt32bits(String keyString, BitArray bitText32) { key obj = new key(keyString); BitArray keyBits = new BitArray(16); Stack keyStack = setKeyStack(keyString); List<BitArray> list = BitOperations.splitKBits(bitText32); BitArray right = new BitArray(16); BitArray left = new BitArray(16); for (int i = 0; i < 8; i++) { keyBits = (BitArray) keyStack.Pop(); 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; }