Exemple #1
0
        public static Challenge3Result GetBestGuessSingleByteXorKey(string hex)
        {
            var source =
                Challenge1.ByteHexToByteArray(hex);

            return(GetBestGuessSingleByteXorKey(source));
        }
        public static string HexXor(string hexA, string hexB)
        {
            if (hexA == null)
            {
                throw new ArgumentNullException("hexA");
            }
            if (hexB == null)
            {
                throw new ArgumentNullException("hexB");
            }
            if (hexA.Length != hexB.Length)
            {
                throw new ArgumentOutOfRangeException("hexA", "both hex strings must be the same length.");
            }

            var bytesA = Challenge1.ByteHexToByteArray(hexA);
            var bytesB = Challenge1.ByteHexToByteArray(hexB);

            var xorBytes  = Xor(bytesA, bytesB);
            var hexResult = ToHex(xorBytes);

            return(hexResult);
        }