Esempio n. 1
0
        /// <summary>
        /// Given:  49276d206b696c6c696e6720796f757220627261696e206c696b65206120706f69736f6e6f7573206d757368726f6f6d
        ///
        /// Output:  SSdtIGtpbGxpbmcgeW91ciBicmFpbiBsaWtlIGEgcG9pc29ub3VzIG11c2hyb29t
        /// </summary>
        /// <param name="hexString"></param>
        public string DoChallenge01(string hexString)
        {
            byte[] byteArray = HexStringToByteArrayConverter.Convert(hexString);

            string output = Convert.ToBase64String(byteArray);

            return(output);
        }
Esempio n. 2
0
        /// <summary>
        /// Given 2 hex strings, compute the XOR
        /// </summary>
        /// <param name="val1">Hex string value 1</param>
        /// <param name="val2">Hex string value 2</param>
        public string DoChallenge02(string val1, string val2)
        {
            //Input values must be the same size
            if (val1.Length != val2.Length)
            {
                throw new Exception("Input values must be the same length.");
            }

            byte[] b1 = HexStringToByteArrayConverter.Convert(val1);
            byte[] b2 = HexStringToByteArrayConverter.Convert(val2);

            byte[] result = XOR.ExclusiveOR(b1, b2);

            return(BitConverter.ToString(result).Replace("-", ""));
        }