Exemple #1
0
        public void CanNormalizeByKeySize()
        {
            var cryptoText = File.ReadAllText(GetTestFilePath("../../../challenge6.txt"));
            var cut        = new HexXorCracker();
            var result     = cut.GetKeySize(cryptoText, Encoding.ASCII);

            Assert.Equal(39, result.Count);
        }
Exemple #2
0
        public void CanHackThatCypherText()
        {
            var expected   = "Cooking MC's like a pound of bacon";
            var cypherText = "1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736";
            var cut        = new HexXorCracker();
            var result     = cut.Crack(cypherText);

            Assert.Equal(expected, result.plainText);
        }
Exemple #3
0
        public void GetKeySizeOfBytesReturnsCorrectValue()
        {
            var input     = new byte[] { 0x01, 0x22, 0x33, 0x44, 0x99, 0x66 };
            var expected1 = new byte[] { 0x01, 0x22, 0x33 };
            var expected2 = new byte[] { 0x44, 0x99, 0x66 };
            var cut       = new HexXorCracker();
            var result1   = cut.GetKeysizeOfBytes(input, 3, 0);
            var result2   = cut.GetKeysizeOfBytes(input, 3, 3);

            Assert.Equal(expected1, result1);
            Assert.Equal(expected2, result2);
        }