Skip to content

Commit

Permalink
set 1 ex 3
Browse files Browse the repository at this point in the history
  • Loading branch information
reteptilian committed Jan 1, 2021
1 parent e4712bd commit fd0aebe
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions exercises/set1/set_1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,4 +102,12 @@ std::string XorHex(absl::string_view hex1, absl::string_view hex2) {
return ConvertBytesToHex(result_bytes);
}

/*
std::string ByteToAscii(absl::string_view hex) {
std::string result;
for (int i = 0; i < hex.size(); ++i) {
result.push_back
}
}
*/
} // namespace cryptopals
5 changes: 5 additions & 0 deletions exercises/set1/set_1_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,9 @@ TEST(Set1Test, Exercise2_FixedXor) {
"746865206b696420646f6e277420706c6179");
}

TEST(Set1Test, Exercise2_SingleByteXorCipher) {
EXPECT_EQ(ConvertHexToBytes(XorHex("1b37373331363f78151b7f2b783431333d78397828372d363c78373e783a393b3736",
"58585858585858585858585858585858585858585858585858585858585858585858")),
"Cooking MC's like a pound of bacon");
}
} // namespace
36 changes: 36 additions & 0 deletions exercises/set1/single_byte_xor_cipher.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
1b 37 37 33 31 36 3f 78 15 1b 7f 2b 78 34 31 33 3d 78 39 78 28 37 2d 36 3c 78 37 3e 78 3a 39 3b 37 36
C o o k i n _ M C _ _ _ i k _ a _ o _ n _ o _ _ a _ o n

space hex 20
78 ^ 20 = 58
36 ^ 58 = 6e

15 ^ 58 = 4d M
1b ^ 58 = 43 C
78 ^ 58 = 20 space
31 ^ 58 = 69 i
33 ^ 58 = 6b k
36 ^ 58 = 6e n
37 ^ 58 = 6f o
39 ^ 58 = 61 a

byte freq likely
15 1
1b 2
28 1
2b 1
2d 1
31 2
33 2
34 1
36 3
37 5 E,T,A,O,I,
39 2
3a 1
3b 1
3c 1
3d 1
3e 1
3f 1
78 6 E,T,A,O,I,N,S,R,H
7f 1

0 comments on commit fd0aebe

Please sign in to comment.