Thread: C++/C Beginners Codebreak challenge

  1. #31
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    b = 1867 char long not the 1210 as first text file. you added more than just a 'd' ?
    I started with the text file from post #17 which is 1866 chars. I have not checked the ciphertext from post 1 because by the time I found this thread rogster001 had already posted the updated version.
    And please edit your post to add some line breaks to the cipher text, it's messing up the forum layout

  2. #32
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    Kat, forget len issues, mike posted 1867 len doc as i had not parsed a capital letter, last doc posted is correct, there is still time to win, get bustin that key!

  3. #33
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    ok. it will not let me edit it. strlen changed in progies. keep getting four or five different words then nothing fits.
    Last edited by kryptkat; 02-13-2010 at 01:47 PM.

  4. #34
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    What wont let u do what? I think you may be in situation where you need to refactor your code because i think your approach flawed from the outset maybe... And this cipher could be broken quick with just half the char count anyway

  5. #35
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    closing date

    I will keep this contest open until 8th March, one user that i am aware of has broken the cipher but has coded in C#, thus i will keep contest open for further seven days, if no improvements are made on the current best effort then i will announce that as winner by default.

  6. #36
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    spent all weekend trying to figure out why the function was not returning the correct results. for example i would send a 'j' and 'a' which should have returned an 'j' but it returned and 'r'. the function looked correct.

    unlike caesar where you have only one rot with this you have several characters that have to fit before anything looks like legible text. even when you find something it may only be accidental and not part of the message or the key. i made a prog that would test keys. found some interesting results.

    with the key of 'troll' it returns 'cezar' in the first line but no other text. also found
    'snap to a' as the first line again with no other text and
    'victory am i' as part of the frst line with no other text. the key must fit before all of the message is displayed. part of the message may be displayed IF and only IF by chance you get a character in the correct spot in the key. with repeats you still have to find what fits .meow or throw fits. but that is what keeps it interesting. . also why it was once considered unbreakable.

  7. #37
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    thats right, it was once considered unbreakable, and as i mentioned earlier if you encrypt the entire text with a random key of the same length ( as in the one time pad system) it has mathematically been proved unbreakable as even with enough computing power to run all the permutations you would also get all the 'wrong' messages also, you could never be sure which was the right one, no good for intelligence gathering.

    well just a few days left so good luck... interesting that cezar was generated as the first word there using troll haha

  8. #38
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    one time pads can be cracked. you just have to go through all the possible combinations.
    that is the easy part. looking through more than 35 giggs of data to find something legible
    that is the hard part.

    thank you.

  9. #39
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by kryptkat
    one time pads can be cracked. you just have to go through all the possible combinations.
    that is the easy part. looking through more than 35 giggs of data to find something legible
    that is the hard part.
    The problem is, does the intercepted order read "monday attack cboard" or is it "do not attack cboard"? With a one time pad, both are equally likely, but if you guess wrong, cboard might be destroyed. This is what is meant by a one time pad being unbreakable. You can find the plain text, but you cannot identify it as the plain text with any confidence because there are so many alternatives that are equally likely to be the original plain text, even after you have discarded those that are not.
    Last edited by laserlight; 03-02-2010 at 05:03 AM.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  10. #40
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472
    you just have to go through all the possible combinations.
    that is the easy part. looking through more than 35 giggs of data to find something legible
    that is the hard part.
    The point is exactly that which has just been reiterated, brute force attack on the one time pad would yield lots of messages that made perfect sense, and thus would be potential candidates for the correct message, thus rendering brute force attack useless.

    in any case it is pure fantasy to even consider brute force attack as a method of attack for a one time pad,apart from the reason already mentioned the permutations are gargantuan and even given enough computing resource the time taken to attack it like this renders it redundant.
    one time pad is just that, the next message sent is a new random key.

  11. #41
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638

    contest entry

    contest entry
    prog cvcvigenerecontestentry.cpp

    compiles using dev cpp

  12. #42
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    dejamewie if a key is found for the vigenere the rest of the text should fall in to place and make sense. if the same is true for the one time pad maybe. there is most likely to be an order to do something rather than an order not to do something. aka attack or retreat in lieu of sit there and do nothing.
    bruteforcie of only thirteen char was 35 gig file. bruteforcie of only 4 was still 2gig found many with prog that are not part of text message or key. found may parts of words that did not fit eighter. finding the correct characters is still a matter of luck and some intellagence for the message interpatation.

  13. #43
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,472

    Contest entry

    Thanks for entry, see board on monday. You r stil missing point about one time pad though methinks, it is unbreakable in terms of pure math, as a stand alone codebreak, fact the pad could be stolen by your spies is a moot point

  14. #44
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by kryptkat
    dejamewie if a key is found for the vigenere the rest of the text should fall in to place and make sense. if the same is true for the one time pad maybe. there is most likely to be an order to do something rather than an order not to do something. aka attack or retreat in lieu of sit there and do nothing.
    I am not sure what you mean by "a key is found", but if rogster001's interpretation is correct then it does not matter, since encryption will always be "broken" if the attacker knows the key - the idea is to keep the key secret.

    I suspect that your idea is this: by performing cryptanalysis on part of the ciphertext (e.g., the first block of a block cipher), one might be able to obtain a possible key that results in plausible plaintext. When one applies the decryption algorithm using this key on the rest of the ciphertext, the rest of the plaintext should fall into place and make sense.

    The flaw in this with respect to the one time pad is that if you perform cryptanalysis on part of the ciphertext, you only get the possible key material that corresponds to that part of the ciphertext. A one time pad is characterised by the fact that there is at least as much key material as there is plaintext, so that every unit (e.g., bit) of the plaintext is encrypted with a different unit of the key material. Therefore, you cannot apply the decryption algorithm using this key on the rest of the ciphertext, since you do not have the key that corresponds to the rest of the ciphertext.

    Furthermore, the key material that you do get is all the possible keys of the length of that portion of ciphertext that corresponds to a message that makes sense. Effectively, you are playing a pure guessing game to guess all sensible messages of that length. This is a rather hopeless task since you simply cannot know which of your guesses is the correct guess, with any confidence at all.

    For example, instead of the two messages that I suggested, maybe the message is actually "kill: kryptkat only!". Since you reasoned that the message was "monday attack cboard", you went to the frontline and sacrificed yourself, thus enabling the enemy to easily achieve their objective. Thank you
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  15. #45
    Registered User
    Join Date
    Jan 2010
    Posts
    412
    Here's my entry. I really have to stop pushing everything ahead of me until the very last minute, I didn't have time to implement all the functions I wanted to include.

    compiles with
    $ g++ -Wall crypt.cpp -o crypt
    for the basic command line version, or
    $ g++ -Wall crypt.cpp -o crypt -DUSE_NCURSES -lncurses
    for the somewhat improved ncurses gui version. Which also includes the command line functionality of course.
    (for windows users; I don't know if ncurses is available as a native windows library or if you have to use cygwin. I have only tested under cygwin and linux.)

    Usage:
    Decrypt a file, printing to stdout
    $ ./crypt d key < inputfile.txt

    Encrypt a file, storing the result in another file
    $ ./crypt e key < inputfile.txt > outputfile.txt

    Replace "key" with the key you want to use for encryption/decryption.

    Key analysis (requires compiling with ncurses)
    $ ./crypt i
    Then press F1 to load an encrypted file, and F2 to determine key length.
    The F3 option isn't implemented yet (not enough time) but was planned to assist in cracking the key by scanning for character frequencies, which is how I found the OP's key in the first place. (except in C#)
    F10 exits the application.

    Quote Originally Posted by rogster001 View Post
    part1 > the program should be able to aid you break the cipher attached and output as plaintext, by accepting a test key. it should include a function to help your analysis of the testkeys, eg funtion to help determine key length by looking for repeated groupings.
    check. See the i option.
    part2 > Your program should also be able to encrypt the attached plaintext file using the same ciphertype and key and output it to a .txt file, this file will then be run in my test program.
    check. See attached "encrypted.txt"

    include the cipherkey as a comment at the top of your source file.
    check. See the first line of crypt.cpp

    The winning program will be a single source file, maximum of 200 lines, including empty lines.
    Uhm.. my source uses a lot more than 200 lines so I failed to fulfill this requirement.

    For those who don't feel like reading the source just to get the key, it's "basic"

    The code has hardly any comments at all, and is quite a mess. (I blame it on being tired, and being high on coffee. It's 5am here) But at least I got a chance to try out ncurses
    If anyone has any questions about something then feel free to ask.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Beginners C Programming Challenge
    By UCnLA in forum C Programming
    Replies: 23
    Last Post: 04-01-2008, 07:46 PM
  2. Beginners C Programming Challenge
    By UCnLA in forum C Programming
    Replies: 2
    Last Post: 03-18-2008, 12:15 PM
  3. for beginner's or anyone interested
    By Iconoklast in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 03-25-2004, 02:45 PM
  4. Requesting a challenge
    By RealityFusion in forum C++ Programming
    Replies: 8
    Last Post: 08-18-2003, 08:24 PM
  5. What is a good beginners' C++ book?
    By GrNxxDaY in forum C++ Programming
    Replies: 1
    Last Post: 07-29-2002, 09:50 AM