[VicPiMakers Projects] Jim's Challenge - Output 10 (caesar cipher)

Patrick McMorris patrick at mcmorris.ca
Sun Oct 11 23:24:00 EDT 2020


That's certainly crafty.

I considered that but again you need to make more assumptions like you're
using the same corpus of words. What if it's not an English word. What if
it's not a regular word but a name. What about words that have multiple
possible matches because multiple rotations are valid? (e.g. "FUSION" and
"LAYOUT"). Then do you output multiple possible keys?




On Sun., Oct. 11, 2020, 7:36 p.m. Mark G., <vpm at palaceofretention.ca> wrote:

> Hi Patrick et al,
>
> I decided that a simple brute force through keys 1-26 and then
> checking the output using a spell checker library could work.
>
> Here's a snippet:
>
> ...
> #include <nuspell/dictionary.hxx>
> #include <nuspell/finder.hxx>
> ...
>
>      // vector for deciphered message
>      std::vector<char> message;
>
>      // Key (unknown) for ceaser cipher.
>      int key = 0;
>
>      int offset {'A'};
>      int message_letter {'0'};
>
>      auto dict_finder = nuspell::Finder::search_all_dirs_for_dicts();
>      auto path = dict_finder.get_dictionary_path("en_US");
>      auto dict = nuspell::Dictionary::load_from_path(path);
>
>      // Go through all keys
>      for (key = 1; key <= 26; key++) {
>
>          message.clear();
>          // letters contains our encrypted text
>          for (const auto letter : letters) {
>              message_letter = offset + (((letter - offset) - key + 26) %
> 26);
>              message.emplace_back(tolower(message_letter));
>          }
>
>          auto word = std::string(message.data(), message.size());
>
>          auto correct = dict.spell(word);
>          if (correct) {
>              break;
>          }
>      }
>      print_output_and_number(output_number++);
>      std::cout << "Key: " << key << std::endl;
>
> ==============
>
> What happens is that each key is tried in turn and a word is created
> out of all 6 letters.  This word is then compared against a spell
> checker, and if a correct result is found, then there is a high
> likelyhood that we've found the key and we break out of the key loop.
>
> This requires no prior knowledge of the plain text, but can be
> computationally expensive.
>
>
>
>
>
>
> On 2020-10-11 3:46 p.m., Patrick McMorris wrote:
> > Ok, thanks.
> >
> > Then there are two inputs; not just the data array. Question 10 implied
> > a second input will be provided.
> >
> > On Sun., Oct. 11, 2020, 3:37 p.m. James Briante, <briantej at gmail.com
> > <mailto:briantej at gmail.com>> wrote:
> >
> >     Hi Patrick,
> >     Here is the last sentence of the comment I posted today at 2:31 PM
> >     "The final test data will include a new string not “BIOPSY”.
> >
> >     Jim
> >
> >
> >
> >     On Sun, Oct 11, 2020 at 3:19 PM Patrick McMorris
> >     <patrick at mcmorris.ca <mailto:patrick at mcmorris.ca>> wrote:
> >
> >         Hello Jim,
> >
> >         Your instructions are unclear and we're just asking you to
> >         clearly address the issue.
> >
> >         If you want our code to output the key used then either we
> >         assume the word is the same or your next update also provides a
> >         new word in addition to a new byte array.
> >
> >         Which is it?
> >
> >         On Sun., Oct. 11, 2020, 2:32 p.m. James Briante,
> >         <briantej at gmail.com <mailto:briantej at gmail.com>> wrote:
> >
> >             Craig, Patrick, Greg & Others,
> >
> >             Note that the string “BIOPSY” is not part of the input data
> >             but included in the description of Output#10 in order to
> >             simplify things. If “BIOPSY” appears in your code, you have
> >             created an *implicit input* to simplify things. The final
> >             test data will include a new string not “BIOPSY”.
> >
> >             Consider the implication of not having known the plaintext
> >             “BIOPSY”. One  solution would be to write separate code (not
> >             part of the solution to Challenge1) that sequentially
> >             reverses the encryption process. Why not do so and then just
> >             print 6 for Output #10?
> >
> >             The above method requires human intervention in order to
> >             recognize meaningful words during the decryption process.
> >             Why not write code to remove the human out of the loop?
> >             Hopefully, that explains why the string *“BIOPSY*” was a
> >             good choice for Challenge 1.
> >
> >             Jim
> >
> >
> >             On Sun, Oct 11, 2020 at 9:52 AM Michelle Wiboltt
> >             <michellewiboltt at outlook.com
> >             <mailto:michellewiboltt at outlook.com>> wrote:
> >
> >                 Also, instead of exclamation! ? for instance, why can’t
> >                 these be illustrated as musical notes so that we come to
> >                 learn /to understand tempo/crescendo/intent...plus,
> >                 “music tames the savage beast”, non? So wouldn’t we want
> >                 to gift “those extraterrestrials” with this type of
> >                 advantage, which is really our advantage in that we set
> >                 the tone:)
> >
> >
>  ------------------------------------------------------------------------
> >                 *From:* Projects <projects-bounces at vicpimakers.ca
> >                 <mailto:projects-bounces at vicpimakers.ca>> on behalf of
> >                 Greg H <greg.horie at gmail.com <mailto:
> greg.horie at gmail.com>>
> >                 *Sent:* Sunday, October 11, 2020 9:43:32 AM
> >                 *To:* Talk about Raspberry Pi / embeded projects
> >                 <projects at vicpimakers.ca <mailto:projects at vicpimakers.ca
> >>
> >                 *Subject:* Re: [VicPiMakers Projects] Jim's Challenge -
> >                 Output 10 (caesar cipher)
> >                 Nice one Eileen! Solving it in Scratch sounds like a
> >                 challenge.
> >
> >                 Has anyone considered trying it in a pure functional
> >                 language?
> >
> >                 https://en.wikipedia.org/wiki/Functional_programming
> >                 <
> https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fen.wikipedia.org%2Fwiki%2FFunctional_programming&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727328950&sdata=h57KpB18orFr3DZDozsMp7Wuu3TI%2BAXKneLt2kXKMHE%3D&reserved=0
> >
> >
> >
> >                 On Sun, 11 Oct 2020 at 09:35, Michelle Wiboltt
> >                 <michellewiboltt at outlook.com
> >                 <mailto:michellewiboltt at outlook.com>> wrote:
> >
> >                     Is it a question of overthinking? Me, I see it as a
> >                     question of “over” feeling things - on steroids, no
> >                     less and from here/there,  building a “visual”
> >                     conceptual foundation of these wonderfully warm
> >                     feelings for all to see/feel/utilize AND understand.
> >
> >                     It kind of needs to contain our existing or newly
> >                     conceived of “absolute love language”...like an and.
> >                     And always conjoins so, what word, string, etc?
> >                     always conjoins the all of the all of us...then, we
> >                     mirror our movement with/by that spin around the
> >                     world thing, same as our world, non?
> >
> >
>  ------------------------------------------------------------------------
> >                     *From:* Projects <projects-bounces at vicpimakers.ca
> >                     <mailto:projects-bounces at vicpimakers.ca>> on behalf
> >                     of Eileen Amirault <cody.eileen at gmail.com
> >                     <mailto:cody.eileen at gmail.com>>
> >                     *Sent:* Sunday, October 11, 2020 9:23:54 AM
> >                     *To:* Talk about Raspberry Pi / embeded projects
> >                     <projects at vicpimakers.ca
> >                     <mailto:projects at vicpimakers.ca>>
> >                     *Subject:* Re: [VicPiMakers Projects] Jim's
> >                     Challenge - Output 10 (caesar cipher)
> >                     Hey everyone,
> >
> >                     Just solved challenge #1 using Scratch. Hope the new
> >                     ‘Test’ data will work just as well. Intend on
> >                     showing you what I did at the end of my presentation
> >                     on Oct 24.
> >
> >                     Have a nice week,
> >                     Eileen
> >
> >>                     On Oct 11, 2020, at 9:15 AM, Michelle Wiboltt
> >>                     <michellewiboltt at outlook.com
> >>                     <mailto:michellewiboltt at outlook.com>> wrote:
> >>
> >>                     Ok, but there IS a watermark? thing...so, this
> >>                     needs to be illustrated meaning, if we’re creating
> >>                     a love �� language we want that to show in its
> >>                     entirety AND if “bad” people “break” in...aren’t
> >>                     they just asking to be included? wouldn’t it be a
> >>                     wanting but not knowing how to be a part of this
> >>                     fabulousity that is the (our) language of love ��
> >>                     So, if they “break” in doesn’t it stand to reason
> >>                     they were left out. Isn’t that our bad?
> >>
> >>                     Also, a language of love would have to be, would
> >>                     need to, continually fortified in order for it to
> >>                     remain foundation-ally strong, right white lights?
> >>                     And, its strength comes from our ever evolving
> >>                     understanding/feeling/sensing/knowing of what our
> >>                     hearts are truly capable of and then, illustrating
> >>                     this in the majesty that WILL be our code that You
> >>                     all create, see?
> >>
> >>                     Also, just a thought, what about that bit coin
> >>                     spin around the world tor thing...if we built our
> >>                     foundation on something like this wouldn’t this
> >>                     keep any nasty extraterrestrials at bay but
> >>                     wouldn’t it also, keep us ALL contained herein,
> >>                     safely.
> >>                     m
> >>
> >>
>  ------------------------------------------------------------------------
> >>                     *From:* Projects <projects-bounces at vicpimakers.ca
> >>                     <mailto:projects-bounces at vicpimakers.ca>> on
> >>                     behalf of Patrick McMorris <patrick at mcmorris.ca
> >>                     <mailto:patrick at mcmorris.ca>>
> >>                     *Sent:* Sunday, October 11, 2020 8:34:44 AM
> >>                     *To:* Talk about Raspberry Pi / embeded projects
> >>                     <projects at vicpimakers.ca
> >>                     <mailto:projects at vicpimakers.ca>>
> >>                     *Subject:* Re: [VicPiMakers Projects] Jim's
> >>                     Challenge - Output 10 (caesar cipher)
> >>                     I agree it's not that clear.
> >>
> >>                     If the goal to be able to simply run the existing
> >>                     code on new input bytes then yes, "BIOPSY" is
> >>                     always the decrypted word since the byte array is
> >>                     the only given input. If the word changes, that
> >>                     hasn't been specified where that input would come
> >>                     from. So, either it doesn't change or the
> >>                     description of the second input is missing.
> >>
> >>                     But using a hard-coded word doesn't sound terribly
> >>                     interesting to code up. You could still write your
> >>                     key finding function to accept two strings of
> >>                     equal length and output the required caesar key.
> >>                     Then for question #10, call it with the word you
> >>                     extract from the input array and the hard-coded
> >>                     target word and write the output key. Then the
> >>                     problem is hard-coded but your code is more generic.
> >>
> >>
> >>                     Patrick
> >>
> >>                     On Sun., Oct. 11, 2020, 8:01 a.m. Greg H,
> >>                     <greg.horie at gmail.com
> >>                     <mailto:greg.horie at gmail.com>> wrote:
> >>
> >>                         For me, the confusion is that we're intended
> >>                         to write code to derive the cipher key value.
> >>                         I did this and came up with an answer, but
> >>                         this key is only relevant "HOUVYE" / "BIOPSY".
> >>
> >>                         So should I take this key and make it a
> >>                         constant for future inputs / encryptions?
> >>                         That's what I ended up doing with my final
> >>                         code submission.
> >>
> >>                         I took out the code that solved the problem
> >>                         because unused code seems like lint to me, but
> >>                         maybe I should put it back to show how I did it.
> >>
> >>
> >>                         On Sat, 10 Oct 2020 at 17:45, James Briante
> >>                         <briantej at gmail.com
> >>                         <mailto:briantej at gmail.com>> wrote:
> >>
> >>                             Hi Patrick,
> >>                              Yes, you can look at only the first
> >>                             character of the string and use it to get
> >>                             the key. Comparing all characters as the
> >>                             advantage of catching errors in
> >>                             encryption/decryption. The code is just as
> >>                             short using  "compare strings"  of your
> >>                             particular language.
> >>
> >>                             In C int strcmp (const char* str1, const
> >>                             char* str2);, in C++
> >>                             *int**CompareText*(*const*AnsiString *S1*,
> >>                             *const*AnsiString *S2*); Pascal ( Delphi)
> >>                             *function**CompareText*(*const**S1*:
> >>                             *string*; *const**S2*: *string*): Integer;
> >>
> >>                             Aside: The purpose of the final test data
> >>                             is to see if your outputs are correct when
> >>                             you run your code with the new data. It
> >>                             should work the first time with no changes
> >>                             in the actual code.
> >>                             Jim
> >>
> >>                             On Sat, Oct 10, 2020 at 4:46 PM George
> >>                             Bowden <gtbowdeng at gmail.com
> >>                             <mailto:gtbowdeng at gmail.com>> wrote:
> >>
> >>                                 Hi Michelle
> >>                                 If you are on a laptop or computer
> >>                                 using chrome, you can hold down the
> >>                                 CTRL key and tap the letter u .  There
> >>                                 are things further back than that but
> >>                                 its a start.  As for ink marks showing
> >>                                 through, we try to avoid that because
> >>                                 it usually reveals security holes that
> >>                                 the bad people exploit.
> >>
> >>                                 On Sat, Oct 10, 2020 at 1:23 PM
> >>                                 Michelle Wiboltt
> >>                                 <michellewiboltt at outlook.com
> >>                                 <mailto:michellewiboltt at outlook.com>>
> >>                                 wrote:
> >>
> >>                                     Please help:)
> >>                                     Here’s where my crazy comes in,
> >>                                     see this image...
> >>                                     <Image.jpeg>
> >>                                     Ok.
> >>
> >>                                     Now, if u could think in terms of
> >>                                     front back / embroidery and its
> >>                                     front back...
> >>                                     So, above is a code interface? But
> >>                                     where is the back front and back?
> >>                                     Front would be the website, right?
> >>                                     So, when I do online shopping,
> >>                                     that’s the front. Where is the
> >>                                     back view of the front of the
> >>                                     website?
> >>
> >>                                     Another example, when writing in
> >>                                     ink it can show through the
> >>                                     backside when held to the light,
> >>                                     kind of thing is what I’m trying
> >>                                     to understand? Where’s that on the
> >>                                     internet?
> >>
> >>                                     Thx
> >>                                     m
> >>
> >>                                     Michelle Wiboltt
> >>                                     www.elb1b69.net
> >>                                     <
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fwww.elb1b69.net%2F&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727328950&sdata=LwqWQoRGJqX8ioMprkuE9VwBOb3JfvgsIpAG0kxAYFs%3D&reserved=0
> >
> >>                                     604-612-2505
> >>
> >>
>  ------------------------------------------------------------------------
> >>                                     *From:* Projects
> >>                                     <projects-bounces at vicpimakers.ca
> >>                                     <mailto:
> projects-bounces at vicpimakers.ca>>
> >>                                     on behalf of Greg H
> >>                                     <greg.horie at gmail.com
> >>                                     <mailto:greg.horie at gmail.com>>
> >>                                     *Sent:* Saturday, October 10, 2020
> >>                                     8:56:49 AM
> >>                                     *To:* projects at vicpimakers.ca
> >>                                     <mailto:projects at vicpimakers.ca>
> >>                                     <projects at vicpimakers.ca
> >>                                     <mailto:projects at vicpimakers.ca>>
> >>                                     *Subject:* [VicPiMakers Projects]
> >>                                     Jim's Challenge - Output 10
> >>                                     (caesar cipher)
> >>                                     I'm looking for clarification on
> >>                                     output 10 - caesar cipher problem.
> >>
> >>                                     Is the intent to calculate the
> >>                                     caesar cipher key value OR is the
> >>                                     intent to encrypt the string with
> >>                                     a pre-determined key? Initially I
> >>                                     thought the question was to
> >>                                     discover the cipher key value, but
> >>                                     on reflection this seems fragile.
> >>
> >>                                     Reasoning:
> >>                                     - "BIOPSY" will work for the 12
> >>                                     integer input that leads to
> >>                                     "HOUVYE", but it will not work for
> >>                                     any 12 random integers.
> >>                                     - You'd have to reverse engineer
> >>                                     your integers starting from
> >>                                     "BIOPSY" to get a valid set of 12
> >>                                     integers.
> >>
> >>                                     I solved it both ways, but posted
> >>                                     only the 2nd solution to github
> >>                                     because only the 2nd solution will
> >>                                     work for a random set of 12
> integers.
> >>
> >>                                     I'm curious how other folks solved
> >>                                     this one.
> >>
> >>                                     --
> >>                                     Projects mailing list
> >>                                     Projects at vicpimakers.ca
> >>                                     <mailto:Projects at vicpimakers.ca>
> >>
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >>                                     <
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727338941&sdata=HBzJ15Bq7rk6Kz7FSFgDePfGdHYHUSGowGj19Gjz7Vk%3D&reserved=0
> >
> >>
> >>
> >>
> >>                                 --
> >>                                 George Bowden, vice president,
> >>                                 Victoria Computer Club
> >>                                 gtbowdeng at gmail.com
> >>                                 <mailto:gtbowdeng at gmail.com>
> >>                                 --
> >>                                 Projects mailing list
> >>                                 Projects at vicpimakers.ca
> >>                                 <mailto:Projects at vicpimakers.ca>
> >>
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >>                                 <
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727338941&sdata=HBzJ15Bq7rk6Kz7FSFgDePfGdHYHUSGowGj19Gjz7Vk%3D&reserved=0
> >
> >>
> >>                             --
> >>                             Projects mailing list
> >>                             Projects at vicpimakers.ca
> >>                             <mailto:Projects at vicpimakers.ca>
> >>
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >>                             <
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727348937&sdata=Prx6%2FauXvOcRkobYJo4RSp9nXDZXaERn%2BZnmYHf2%2Boo%3D&reserved=0
> >
> >>
> >>                         --
> >>                         Projects mailing list
> >>                         Projects at vicpimakers.ca
> >>                         <mailto:Projects at vicpimakers.ca>
> >>
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >>                         <
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727348937&sdata=Prx6%2FauXvOcRkobYJo4RSp9nXDZXaERn%2BZnmYHf2%2Boo%3D&reserved=0
> >
> >>
> >>                     --
> >>                     Projects mailing list
> >>                     Projects at vicpimakers.ca
> >>                     <mailto:Projects at vicpimakers.ca>
> >>
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >>                     <
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727358931&sdata=diiLJdgTh%2F13a0MlkTz3NrHKTNpRVwuL%2FVshqbPts4w%3D&reserved=0
> >
> >
> >                     --
> >                     Projects mailing list
> >                     Projects at vicpimakers.ca <mailto:
> Projects at vicpimakers.ca>
> >
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >                     <
> https://nam10.safelinks.protection.outlook.com/?url=http%3A%2F%2Fvicpimakers.ca%2Fmailman%2Flistinfo%2Fprojects_vicpimakers.ca&data=02%7C01%7C%7Cbe8d0cc14e5245e5aa3808d86e04ed6a%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637380314727358931&sdata=diiLJdgTh%2F13a0MlkTz3NrHKTNpRVwuL%2FVshqbPts4w%3D&reserved=0
> >
> >
> >                 --
> >                 Projects mailing list
> >                 Projects at vicpimakers.ca <mailto:Projects at vicpimakers.ca>
> >
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >
> >             --
> >             Projects mailing list
> >             Projects at vicpimakers.ca <mailto:Projects at vicpimakers.ca>
> >
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >
> >         --
> >         Projects mailing list
> >         Projects at vicpimakers.ca <mailto:Projects at vicpimakers.ca>
> >         http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >
> >     --
> >     Projects mailing list
> >     Projects at vicpimakers.ca <mailto:Projects at vicpimakers.ca>
> >     http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
> >
> >
>
> --
> Projects mailing list
> Projects at vicpimakers.ca
> http://vicpimakers.ca/mailman/listinfo/projects_vicpimakers.ca
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://vicpimakers.ca/pipermail/projects_vicpimakers.ca/attachments/20201011/b33c0188/attachment.htm>


More information about the Projects mailing list