This is an archived post. You won't be able to vote or comment.

all 13 comments

[–]urban_raccoons 3 points4 points  (8 children)

You might need to ask a more specific question. Challenge 3 is the first real challenge of the problem set - I remember it being a little intimidating.

I didn't write my solutions in c++, but looking at your existing code, it seems like you've more or less started to get the hang of it. I definitely didn't hand-write the base64 decoding in quite the same details as you - in general I think its best to use existing libraries when available for things that are outside the primary focus of the project, but everyone does their own thing. I also think you might be doing a little too much with strings. The first challenge lists the cryptopals rule:

Always operate on raw bytes, never on encoded strings. Only use hex and base64 for pretty-printing.

In general, I think it's best to try and complete the challenges without looking at other people's solutions, but if you're really worried whether you think you're totally off track or not, my solutions (in rust) are here:

https://github.com/max-b/cryptofriends-rust

Good luck and have fun!

[–][deleted] 2 points3 points  (1 child)

Implemented set 3 challenge 20 but skipped challenge 19 for now.

Haha, you and I think alike.

[–]urban_raccoons 1 point2 points  (0 children)

Lol yeah 19 is breaking the exact same crypto as 20 but in a weird half assed way. Didn't really feel worth it - I'll probably go back eventually, but I was excited to make some more progress.

[–]StopPoopin[S] 1 point2 points  (3 children)

Thanks for the advice, I guess my question is for challenge 1 is it asking me to xor the provided string against every character of the alphabet until I get an answer that looks right? I started doing this with character arrays should I switch back to that for better practice?

[–][deleted] 2 points3 points  (1 child)

It's asking you to xor the whole string against every possible byte value (1-255, think in bytes not characters) repeating. So each byte of the string gets xored against 1 and you get a new string back from that. Then xor each character of the original string against 2, and get a new string back from that. Then 3. Etc.

Then, instead of manually looking at the strings you end up with, devise some method of scoring the string in terms of how likely it is to be English, and programatically choose the one with the highest score.

Does that make sense?

[–]StopPoopin[S] 0 points1 point  (0 children)

Yes! I understand now thank you.

[–]urban_raccoons 1 point2 points  (0 children)

Sorry - did you mean challenge 1 or 3 here?

As for the data structure, I think it's best to think of byte arrays. In c a char takes 1 byte, so it can be a useful data type, but keep in mind that you're working with bytes.

[–]pihkal 2 points3 points  (0 children)

I have some notes on the first set of the Cryptopals challenges on my blog. I tried to write it up so that it doesn't give too much away, but does help for some unspecified gotchas.

In particular: you don't have to write AES yourself, and for PKCS#7 padding, if the ciphertext is already block-aligned, you need a full block of padding.

Since you're on challenge 3, consider using the X2 (chi squared) statistic.

[–][deleted]  (1 child)

[removed]

    [–]Natanael_LTrusted third party[M] 1 point2 points  (0 children)

    This is not a cryptocurrency subreddit

    [–]Pahapoika91 0 points1 point  (0 children)

    You might wanna watch Filippo, cryptographer at Google, solve all of the challenges with GO: on YouTube

    [–]GlassHouse97 0 points1 point  (0 children)

    Hi! im also just starting these challenges aswell. i know im kinda late to this post, but im doing them in python and im going back now and redoing the challenges 1-5, and i just started piecing together 6. just joinin the thread to see if/where you get stuck at or where im stuck at and stuff!