C++/C Beginners Codebreak challenge

This is a discussion on C++/C Beginners Codebreak challenge within the Contests Board forums, part of the Community Boards category; I thought it an idea to put a puzzle up for the less advanced programmers like myself to have a ...

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

    C++/C Beginners Codebreak challenge

    I thought it an idea to put a puzzle up for the less advanced programmers like myself to have a go at, this is a mixture of codebreaking and program creation, the point being building a program as a tool to break the code, without it this would take a long time to solve, unless you were born in bletchley park or something.

    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.
    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.

    I dont think it will take too long for someone to complete it so public answers posted here as attachments,

    include the cipherkey as a comment at the top of your source file.
    if you have the key correct but your program does not accurately output the plaintext thats a fail.

    in the same format of my ciphertext (ie no whitespace, all lowercase letters, no punctuation)

    console app only.

    i use codeblocks but also have dev cpp so those are my options to compile your work, so ensure compatible.

    The winning program will be a single source file, maximum of 200 lines, including empty lines.

    only the usual headers for i/o allowed

    This is a Vigenère cipher.

    To the winner goes the glory, adulation of your peers, + people will no longer cross the street to avoid you! Also it might be a step on the road to solve the Beale papers...

    p.s i suppose its possible someone already has something to do this....so maybe let others have a go if so !
    Attached Files Attached Files
    Last edited by rogster001; 12-16-2009 at 01:11 AM. Reason: familiarity breeds contempt! ;->

  2. #2
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    you mean Vigenère cipher. meow.

  3. #3
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,637
    I'm doing this by hand but I don't completely understand the instructions.

    The Vigenère cipher function is essentially modulo arithmetic, and thus commutative. So if the key length is known (or guessed) then subtracting the cipher text from itself, offset by the key length will produce the cipher text encrypted with itself. If any words in the cipher text are known or can be guessed at then the plain text and hence the key will be revealed. This is useful if the key is an obscure sequence of letters because the plain text will generally be ordinary words.
    By the way I hate you for picking now to do this, but if I can crack it by hand, I will be able to write it algorithmically.... though there is not much a point at that point.
    Last edited by whiteflags; 12-18-2009 at 08:35 PM.

  4. #4
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409

    Method or madness

    That is confusin description yes but wil make sense hindsight,several methods t attack this ciphertype,seek altern, 1st analysis is try determine keylength, laborious to crack by hand hence write program, merry christmas;-)!

  5. #5
    Registered User jeffcobb's Avatar
    Join Date
    Dec 2009
    Location
    Henderson, NV
    Posts
    875
    When my wife and I first met we needed a secure method of exchanging "letters" and I came up with an algorithm to do so. The trick is that each message contained the key for the next one. Years later we can upon these messages and wanted to see what was in them but as with all things, memory degrades over time. I told you all of that simply to say that writing a code-breaker for those messages was a VERY interesting project......so this could be a great deal of fun. One approach involved using a dictionary to decode the first 100 bytes of the message, then "spell check" the resulting text. If the spell checker claimed more than a 50% success rate, the rest of the message was decoded using that word. This broke about 80% of the messages....not perfect but it had promise.
    C/C++ Environment: GNU CC/Emacs
    Make system: CMake
    Debuggers: Valgrind/GDB

  6. #6
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409

    Unbreakable

    Yea, its a great exercise 4algorithms and similar t your point vignere cipher once considerd unbreakable,thing is using 1 time pad, bit like ur exampl can b made truly unbreakble cos even wit quantum power would only ever reveal all wrong messages also

  7. #7
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    Yea, its a great exercise 4algorithms and similar t your point vignere cipher once considerd unbreakable,thing is using 1 time pad, bit like ur exampl can b made truly unbreakble cos even wit quantum power would only ever reveal all wrong messages also
    Erm....what?

    When my wife and I first met we needed a secure method of exchanging "letters" and I came up with an algorithm to do so. The trick is that each message contained the key for the next one. Years later we can upon these messages and wanted to see what was in them but as with all things, memory degrades over time. I told you all of that simply to say that writing a code-breaker for those messages was a VERY interesting project......so this could be a great deal of fun. One approach involved using a dictionary to decode the first 100 bytes of the message, then "spell check" the resulting text. If the spell checker claimed more than a 50% success rate, the rest of the message was decoded using that word. This broke about 80% of the messages....not perfect but it had promise.
    So I guess there was no way after that for you to hide your nerdiness and be 'cool' in her eyes? She definitely knew that she was marrying a nerd. But that's cool b/c nerd husbands are in high demand now. Ladies just about die when their e-mail and facebook don't work and so it's nerd husbands to the rescue. I'm thinking about getting a cape but that's probably going overboard.


    Anyways, sounds like a fun challenge. I might give it a go.
    Last edited by VirtualAce; 12-22-2009 at 12:56 AM.

  8. #8
    Registered User whiteflags's Avatar
    Join Date
    Apr 2006
    Location
    United States
    Posts
    7,637
    Quote Originally Posted by rogster001 View Post
    Yea, its a great exercise 4algorithms and similar t your point vignere cipher once considerd unbreakable,thing is using 1 time pad, bit like ur exampl can b made truly unbreakble cos even wit quantum power would only ever reveal all wrong messages also
    I'm not wasting my time trying to crack a one-time pad if that's what your challenge is.

  9. #9
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    adulation of your peers
    That's an odd incentive... perhaps the admiration of my peers...?
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  10. #10
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409

    Tidy up

    Whiteflags no way is it one time pad man, that would be nuts, to cactus hugger.. Use of word 'adulation' used in sense of 'tongue in cheek' to all, will tidy my post up for clarity, been away from pc and unable to reply properly
    Last edited by rogster001; 12-23-2009 at 01:56 AM.

  11. #11
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409
    why cant i edit my original post? the button is only available on my last comment? anyway this line in the instructions >
    in the same format of my ciphertext (ie no whitespace, all lowercase letters, no
    punctuation)
    it should be 'your encrypted file should output in the same format as my ciphertext (ie no whitespace, all lowercase letters, no
    punctuation)'

    also because people may use different approaches to crack the cipher i think the requirements for the actual program pass need clarifying.

    It is fundamental to try and determine the length of key, so your program must include a function that scans the coded document comparing sample length strings in the cipher for repeats,
    Output the number of ocurrences for matching strings.
    You can also complete this step by assuming a words like 'the' or 'then' exisit in the plaintext and by reversing how you use the alphabet grid by using 'the' to decrypt examine this output for repeat patterns that may provide clues to key.

    note candidates for further analysis are normally only those with more than 2 hits, depending on the sample length you try, 2 or less may just be coincidence.

    There would usually be a couple more analysis stages, the first would probably be a frequency test, but like i say there are different ways so it is hard to set the requirements without effectively outlining a step by step method myself and thus making the puzzle easier for those that just want to crack code.
    So i will allow two additional functions that will not contribute to the total line count to help you with the final analysis, or complete this part by hand.
    Any other suggestions welcome, if anyone thinks just change the requirements so that three functions for analysis are included or whatever.
    Last edited by rogster001; 12-24-2009 at 12:59 AM.

  12. #12
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    do you know what the key is on that cipherdoc.txt ?

  13. #13
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409
    Quote Originally Posted by kryptkat View Post
    do you know what the key is on that cipherdoc.txt ?
    Eh? Of course yes, its my encryption, thats the game

  14. #14
    Registered User kryptkat's Avatar
    Join Date
    Dec 2002
    Posts
    638
    your encryption ? you mean your key using Vigenère ?

    this is from a small function to extract that key. how did it do ?
    Attached Files Attached Files

  15. #15
    Registered User rogster001's Avatar
    Join Date
    Aug 2006
    Location
    Liverpool UK
    Posts
    1,409
    your encryption ? you mean your key using Vigenère ?
    ?? i mean i created the encrypted file using Vignére cipher and a key of my choosing, i hope thats a good enough reply

    i will have a look at the file now cheers

    >>

    Sorry Kryptkat, but i am not sure what you are showing here, if this is your submission for the 'encrypt the plaintext' part of the puzzle then it does not work with my key, it just produces what looks like another coded document.
    also your character count is wrong so you must be going wrong somewhere there, if you eliminated all whitespace and punctuation it should be 1210, your document is 1184.

    what key length are you testing?

    The grid you have in the text file does not include the indexes, maybe you are taking this into account in your actual code but just not the printout, i am just suggesting maybe this was an oversight? or maybe you are just working the grid some other way without the need for the index
    Last edited by rogster001; 01-26-2010 at 04:36 AM.

Page 1 of 4 1234 LastLast
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, 01: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21