public void HexStrings() { const string x = "4154"; // 65 84 const string y = "534f"; // 83 79 Xor.HexStrings(x, y).Should().Be("121b"); }
public void Challenge2() // XOR { const string hex1 = "1c0111001f010100061a024b53535009181c"; const string hex2 = "686974207468652062756c6c277320657965"; const string expected = "746865206b696420646f6e277420706c6179"; Xor.HexStrings(hex1, hex2).Should().Be(expected); }
public void Challenge5() // repeating-key XOR { const string plaintext = "Burning 'em, if you ain't quick and nimble\nI go crazy when I hear a cymbal"; const string key = "ICE"; const string expected = "0b3637272a2b2e63622c2e69692a23693a2a3c6324202d623d63343c2a26226324272765272a282b2f20430a652e2c652a3124333a653e2b2027630c692b20283165286326302e27282f"; var textAsBytes = Encoding.UTF8.GetBytes(plaintext); var textAsHex = Hex.BytesToString(textAsBytes); var keyAsBytes = Encoding.UTF8.GetBytes(key); var keyAsHex = Hex.BytesToString(keyAsBytes); var expandedKey = Xor.ExpandKey(textAsHex, keyAsHex); var cipherText = Xor.HexStrings(textAsHex, expandedKey); cipherText.Should().Be(expected); }