Example #1
0
        private int GetCountOfPossibleKeysTo1Byte(int iteration)
        {
            var oldList = new List <string>();
            var newList = new List <string>();

            for (var i = 0; i < messages.Count; i++)
            {
                newList = GeneratePossibleListOfKeys(messages[i][iteration], hammingWeights[i][iteration]);
                if (i == 0)
                {
                    oldList.AddRange(newList);
                }
                else
                {
                    oldList = newList.Intersect(oldList).ToList();
                }
            }
            Key[iteration] = (oldList.Count == 1) ? NumberExtension.ConvertBinToHex(oldList.First()) : string.Empty;

            possibleKeyBytes.Add(CollectionExtension.ConvertListOfBinToHex(oldList));

            return(oldList.Count);
        }
Example #2
0
 public static string XORhex(this string first, string second) =>
 NumberExtension.ConvertBinToHex(NumberExtension.ConvertHexToBin(first).XORbin(NumberExtension.ConvertHexToBin(second)));