{"id":6201,"date":"2015-10-30T09:35:24","date_gmt":"2015-10-30T13:35:24","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=6201"},"modified":"2020-12-17T16:30:06","modified_gmt":"2020-12-17T21:30:06","slug":"enigma","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2015\/10\/30\/enigma\/","title":{"rendered":"Enigma"},"content":{"rendered":"<div xmlns:mwsh=\"https:\/\/www.mathworks.com\/namespace\/mcode\/v1\/syntaxhighlight.dtd\" class=\"content\">\r\n   <introduction>\r\n      <p><a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495\">Sean<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/51009-enigma\">Enigma<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4370178\">Matt Brauer<\/a> and the Engima MATLAB Team.\r\n      <\/p>\r\n   <\/introduction>\r\n   <h3>Contents<\/h3>\r\n   <div>\r\n      <ul>\r\n         <li><a href=\"#1\">Video<\/a><\/li>\r\n         <li><a href=\"#2\">Background<\/a><\/li>\r\n         <li><a href=\"#3\">WWII Museum<\/a><\/li>\r\n         <li><a href=\"#4\">Using MATLAB Enigma<\/a><\/li>\r\n         <li><a href=\"#13\">Summary<\/a><\/li>\r\n         <li><a href=\"#14\">Comments<\/a><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <h3>Video<a name=\"1\"><\/a><\/h3>\r\n   <p>First, check out this video from the MathWorks' quarterly meeting where the Enigma app was debuted to the company!<\/p>\r\n   <p>\r\n       <!-- Start of Brightcove Player -->\r\n<div class=\"row\"><div class=\"col-xs-12 containing-block\"><div class=\"bc-outer-container add_margin_20\"><videoplayer><div class=\"video-js-container\"><video data-video-id=\"4517936549001\" data-video-category=\"blog\" data-autostart=\"false\" data-account=\"62009828001\" data-omniture-account=\"mathwgbl\" data-player=\"rJ9XCz2Sx\" data-embed=\"default\" id=\"mathworks-brightcove-player\" class=\"video-js\" controls><\/video><script src=\"\/\/players.brightcove.net\/62009828001\/rJ9XCz2Sx_default\/index.min.js\"><\/script><script>if (typeof(playerLoaded) === 'undefined') {var playerLoaded = false;}(function isVideojsDefined() {if (typeof(videojs) !== 'undefined') {videojs(\"mathworks-brightcove-player\").on('loadedmetadata', function() {playerLoaded = true;});} else {setTimeout(isVideojsDefined, 10);}})();<\/script><\/div><\/videoplayer><\/div><\/div><\/div>       \r\n   <\/p>\r\n   <h3>Background<a name=\"2\"><\/a><\/h3>\r\n   <p>On a flight home in March, <a href=\"https:\/\/en.wikipedia.org\/wiki\/The_Imitation_Game\">The Imitation Game<\/a> was showing on the plane.  It was a great movie and made quick work of the flight, but I did not think anything of it being\r\n      related to MATLAB or MathWorks.  A few weeks later, <a href=\"https:\/\/blogs.mathworks.com\/seth\/\">Seth<\/a> contacted a few of us to build a MATLAB version of the Enigma machine. Here's a summary of the email body:\r\n   <\/p>\r\n   <p><hr><\/p>\r\n   <p><i>Have you seen the movie &#8220;The Imitation Game&#8221; about Alan Turing&#8217;s work cracking the Enigma code in WWII?  Turing had a student\r\n         &#8211; Wilkinson. Wilkinson had a student named Moler... <a href=\"https:\/\/blogs.mathworks.com\/cleve\/\">Cleve<\/a> will talk at the company meeting about the connection between Alan Turing and MATLAB. <a href=\"https:\/\/www.mathworks.com\/company\/aboutus\/founders\/jacklittle.html\">Jack<\/a> suggested we get a real Enigma machine, build a MATLAB App to emulate it, and send a message between the two.<\/i><\/p>\r\n   <p><i><b>Parameters:<\/b><\/i><\/p>\r\n   <div>\r\n      <ul>\r\n         <li><i>We do not need to build it from scratch.<\/i><\/li>\r\n         <li><i>Anything we demo should fit with our coding standards.<\/i><\/li>\r\n         <li><i>We should design review it with <a href=\"https:\/\/blogs.mathworks.com\/steve\/\">Steve Eddins<\/a>, <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869375-michelle-hirsch\">Michelle Hirsch<\/a>, Jack and Cleve.<\/i><\/li>\r\n      <\/ul>\r\n   <\/div>\r\n   <p><i>The company meeting is 3 weeks from today. GO!<\/i><\/p>\r\n   <p><hr><\/p>\r\n   <p>We quickly got to talking about high-level requirements and interface designs.  These were the three biggest requirements:<\/p>\r\n   <div>\r\n      <ol>\r\n         <li>It needed to be easily usable at the command line without a user interface.<\/li>\r\n         <li>The user interface needed to look good and use only images MathWorks owns.<\/li>\r\n         <li>It needed to be able to handle multiple models of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Enigma_rotor_details\">rotors and reflectors<\/a>.\r\n         <\/li>\r\n      <\/ol>\r\n   <\/div>\r\n   <p>For the high-level functional design, it was decided that everything would be object oriented.  By doing this, it would allow\r\n      for the different mechanical components to act on their own and maintain state just like in the real machine.  By using <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/matlab_oop\/events-and-listeners.html\">events and listeners<\/a>, each component could announce events as they happen.  If the user interface exists, it would hear those events and update\r\n      automatically, separating the front end from the computation engine.  Another nice side effect of using this design paradigm\r\n      is that we could easily partition the work amongst the team.\r\n   <\/p>\r\n   <p>The entire project was under Git source control with the remote repository living on an internal server.  This allowed us\r\n      to push and pull updates often but to also work offline.\r\n   <\/p>\r\n   <p>Over the next few days we emailed new ideas back and forth to come up with a look and feel.  After that, we split the work\r\n      into pieces: pushing and pulling the changes from Git, each working on our own component, and emailing ideas\/concerns back\r\n      and forth.  About a week later, we had a basic working prototype.\r\n   <\/p>\r\n   <h3>WWII Museum<a name=\"3\"><\/a><\/h3>\r\n   <p>In order to test the MATLAB version of our Enigma Machine, we were given a few hours to experiment with three real machines.\r\n       These Enigma Machines were available at the <a href=\"\">World War II museum<\/a> in Natick, Massachusetts, a few miles from MathWorks' headquarters.  We had no idea what to expect at the museum, figuring\r\n      the museum director, Kenneth Rendell, would probably use the machines in front of us.  <b>No.<\/b>  We were granted special full access to them for two hours; an amazingly generous gift from Kenneth.  We took the machines\r\n      apart, learned what rotors and reflectors were in these machines, etc.  If you ever wondered about an engineering equivalent\r\n      to a kid in a candy shop...\r\n   <\/p>\r\n   <p>Two of the real machines could exchange messages with each other. However, our MATLAB version couldn't correctly decrypt messages\r\n      from the real machines.  We realized that we had not implemented the ring setting, an additional offset.  It took about an\r\n      hour of desperate <tt>circshift<\/tt>-ing by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4758131-corey-lagunowich\">Corey<\/a> and troubleshooting every setting on the machine to finally get the machines to talk.\r\n   <\/p>\r\n   <p>During the troubleshooting time we used the real machines and did a few experiments recording the results for further testing\r\n      back at the office. One experiment was hitting the same letter over and over again about 200 times recording the results of\r\n      how everything shifted.  The other experiment was to hit each letter from the initial rotor setting, reset the rotor, and\r\n      hit the button again.  All of this data became crucial later to identify a physical double stepping behavior in the actual\r\n      Enigma Machines.\r\n   <\/p>\r\n   <p>If you're ever in Natick, I'd encourage you to go to the World War II museum.  The hours and tour schedule are on the website.  It's far more interesting than the mall.\r\n   <\/p>\r\n   <h3>Using MATLAB Enigma<a name=\"4\"><\/a><\/h3>\r\n   <p>Let's take a quick walk through using MATLAB Engima.  There are two ways you can use it, both with and without a user interface.\r\n       Let's first use the UI.\r\n   <\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">launchEnigma<\/pre><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainEnigma\/enigma1.png\"> <\/p>\r\n   <p>Use the gear icon in the upper right-hand corner to configure the components and plugboard.<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainEnigma\/enigma2.png\"> <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainEnigma\/enigma3.png\"> <\/p>\r\n   <p>Use the mouse scroll wheel over the rotor or left-click and drag for the initial rotor settings.<\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainEnigma\/enigma4.png\"> <\/p>\r\n   <p>Type your message using your keyboard or by pushing the letter keys on the screen!  The keys and indicators will light up\r\n      as you type.\r\n   <\/p>\r\n   <p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainEnigma\/enigma5.png\"> <\/p>\r\n   <p>Now you can <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/?utf8=%E2%9C%93&amp;term=morse+code\">morse code<\/a> that message to your friend.\r\n   <\/p>\r\n   <p>How about with the command line?<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">MyEnigma = enigma;<\/pre><p>Select the rotors.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">MyEnigma.Rotors = {<span style=\"color: #A020F0\">'V'<\/span> <span style=\"color: #A020F0\">'II'<\/span> <span style=\"color: #A020F0\">'I'<\/span>};<\/pre><p>Set the ring offset.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">MyEnigma.RingSettings = [1 11 5];<\/pre><p>Select the reflector.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">MyEnigma.Reflector = <span style=\"color: #A020F0\">'B'<\/span>;<\/pre><p>Rotate the rotors to the desired position.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">MyEnigma.RotorSettings = <span style=\"color: #A020F0\">'PBR'<\/span>;<\/pre><p>Connect the plugboard.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">connectPlug(MyEnigma,<span style=\"color: #A020F0\">'QWERASDFPYC'<\/span>,<span style=\"color: #A020F0\">'ZUIOGJKLVHM'<\/span>);<\/pre><p>Perform the encryption.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">encryptedmsg = run(MyEnigma,<span style=\"color: #A020F0\">'THANKYOUFORREADING'<\/span>);\r\ndisp(encryptedmsg)<\/pre><pre style=\"font-style:oblique\">QATIALEVRLXSWXBTEC\r\n<\/pre><p>The machine knows its state, so you can see that in the command line display.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">disp(MyEnigma)<\/pre><pre style=\"font-style:oblique\"> enigma M3 Emulator\r\n\r\n                      L    C    R\r\n \r\n   Rotors:            V   II    I\r\n   Ring Offsets:      1   11    5\r\n   Rotor Settings:    P    B    J\r\n \r\n   Reflector:     B\r\n \r\n   Wired Plug Connections:\r\n     A C D E F G H I J K L M O P Q R S U V W Y Z \r\n     | | | | | | | | | | | | | | | | | | | | | | \r\n     G M K I L A Y E S D F C R V Z O J W P U H Q \r\n \r\n   Input Log:\r\n     THANKYOUFORREADING\r\n \r\n   Output Log:\r\n     QATIALEVRLXSWXBTEC\r\n<\/pre><p>And finally, clear the log to cover your tracks in case your office is compromised.<\/p><pre style=\"background: #F9F7F3; padding: 10px; border: 1px solid rgb(200,200,200)\">clearLog(MyEnigma)<\/pre><h3>Summary<a name=\"13\"><\/a><\/h3>\r\n   <p>This was obviously a really fun project for all involved.  In terms of software, we demonstrated what can be done with MATLAB\r\n      Graphics, fully utilized the <a href=\"https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/source-control.html\">integrated Git source control<\/a> from within MATLAB, worked collaboratively on a short deadline, and demonstrated a good example of an architecture for building\r\n      applications with a user interface.\r\n   <\/p>\r\n   <p>Of course, we also learned a lot about how these machines work and what an engineering marvel they really are!  Thanks again\r\n      to Kenneth from the WWII museum for granting us access to the machines and helping with our questions.\r\n   <\/p>\r\n   <p>For more information on the history and the algorithm implementation in MATLAB, check out <a href=\"https:\/\/www.mathworks.com\/company\/newsletters\/articles\/alan-turing-and-his-connections-to-matlab.html\">this entry in Cleve's Corner<\/a>.\r\n   <\/p>\r\n   <h3>Comments<a name=\"14\"><\/a><\/h3>\r\n   <p>Watch the video, give the app a try and let us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=6201#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/51009-enigma#comments\">comment<\/a> for the Enigma Team.\r\n   <\/p><script language=\"JavaScript\">\r\n<!--\r\n\r\n    function grabCode_a2e43392c77b43538eec2546dc6e7960() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='a2e43392c77b43538eec2546dc6e7960 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' a2e43392c77b43538eec2546dc6e7960';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        author = 'Sean de Wolski';\r\n        copyright = 'Copyright 2015 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add author and copyright lines at the bottom if specified.\r\n        if ((author.length > 0) || (copyright.length > 0)) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (author.length > 0) {\r\n                d.writeln('% _' + author + '_');\r\n            }\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n      \r\n      d.title = title + ' (MATLAB code)';\r\n      d.close();\r\n      }   \r\n      \r\n-->\r\n<\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_a2e43392c77b43538eec2546dc6e7960()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n            the MATLAB code \r\n            <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2015b<br><\/p>\r\n<\/div>\r\n<!--\r\na2e43392c77b43538eec2546dc6e7960 ##### SOURCE BEGIN #####\r\n%% Enigma\r\n%\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/3208495 Sean>'s pick this week is\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/51009-enigma Enigma> by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4370178 Matt Brauer> and the Engima MATLAB Team.\r\n% \r\n\r\n%% Video\r\n%\r\n% First, check out this video from the MathWorks' quarterly meeting where\r\n% the Enigma app was debuted to the company!  \r\n%\r\n% Embed Video Here\r\n\r\n\r\n%% Background\r\n% \r\n% On a flight home in March,\r\n% <https:\/\/en.wikipedia.org\/wiki\/The_Imitation_Game The Imitation Game> was\r\n% showing on the plane.  It was a great movie and made quick work of the\r\n% flight, but I did not think anything of it being related to MATLAB or\r\n% MathWorks.  A few weeks later, <https:\/\/blogs.mathworks.com\/seth\/ Seth>\r\n% contacted a few of us to build a MATLAB version of the Enigma machine. \r\n% Here's a summary of the email body:\r\n%\r\n% <html><hr><\/html>\r\n%\r\n% _Have you seen the movie \u00e2\u20ac\u0153The Imitation Game\u00e2\u20ac\ufffd about Alan Turing\u00e2\u20ac&#x2122;s work\r\n% cracking the Enigma code in WWII?  Turing had a student \u00e2\u20ac\u201c Wilkinson.\r\n% Wilkinson had a student named Moler... <https:\/\/blogs.mathworks.com\/cleve\/\r\n% Cleve> will talk at the company meeting about the connection between Alan\r\n% Turing and MATLAB.\r\n% <https:\/\/www.mathworks.com\/company\/aboutus\/founders\/jacklittle.html Jack>\r\n% suggested we get a real Enigma machine, build a MATLAB App to emulate it,\r\n% and send a message between the two._\r\n%\r\n% _*Parameters:*_\r\n%\r\n% * _We do not need to build it from scratch._\r\n% * _Anything we demo should fit with our coding standards._\r\n% * _We should design review it with <https:\/\/blogs.mathworks.com\/steve\/ Steve Eddins>, <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/869375-michelle-hirsch Michelle Hirsch>, Jack and Cleve._\r\n% \r\n% _The company meeting is 3 weeks from today. GO!_\r\n% \r\n% <html><hr><\/html>\r\n%\r\n% We quickly got to talking about high-level requirements and interface\r\n% designs.  These were the three biggest requirements:\r\n%\r\n% # It needed to be easily usable at the command line without a user interface.\r\n% # The user interface needed to look good and use only images MathWorks owns.\r\n% # It needed to be able to handle multiple models of\r\n% <https:\/\/en.wikipedia.org\/wiki\/Enigma_rotor_details rotors and reflectors>.\r\n%\r\n% For the high-level functional design, it was decided that everything\r\n% would be object oriented.  By doing this, it would allow for the\r\n% different mechanical components to act on their own and maintain state\r\n% just like in the real machine.  By using\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/matlab_oop\/events-and-listeners.html\r\n% events and listeners>, each component could announce events as they\r\n% happen.  If the user interface exists, it would hear those events and\r\n% update automatically, separating the front end from the computation\r\n% engine.  Another nice side effect of using this design paradigm is that\r\n% we could easily partition the work amongst the team.\r\n%\r\n% The entire project was under Git source control with the remote\r\n% repository living on an internal server.  This allowed us to push and\r\n% pull updates often but to also work offline.\r\n%\r\n% Over the next few days we emailed new ideas back and forth to\r\n% come up with a look and feel.  After that, we split the work into pieces:\r\n% pushing and pulling the changes from Git, each working on our own\r\n% component, and emailing ideas\/concerns back and forth.  About a week\r\n% later, we had a basic working prototype.\r\n\r\n%% WWII Museum\r\n%\r\n% In order to test the MATLAB version of our Enigma Machine, we were given\r\n% a few hours to experiment with three real machines.  These Enigma\r\n% Machines were available at the < World\r\n% War II museum> in Natick, Massachusetts, a few miles from MathWorks'\r\n% headquarters.  We had no idea what to expect at the museum, figuring the\r\n% museum director, Kenneth Rendell, would probably use the machines in\r\n% front of us.  *No.*  We were granted special full access to them for two\r\n% hours; an amazingly generous gift from Kenneth.  We took the machines\r\n% apart, learned what rotors and reflectors were in these machines,\r\n% etc.  If you ever wondered about an engineering equivalent to a kid in a\r\n% candy shop...\r\n%\r\n% Two of the real machines could exchange messages with each other.\r\n% However, our MATLAB version couldn't correctly decrypt messages from the\r\n% real machines.  We realized that we had not implemented the ring setting,\r\n% an additional offset.  It took about an hour of desperate |circshift|-ing\r\n% by\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/profile\/authors\/4758131-corey-lagunowich\r\n% Corey> and troubleshooting every setting on the machine to finally get\r\n% the machines to talk.\r\n%\r\n% During the troubleshooting time we used the real machines and did a few\r\n% experiments recording the results for further testing back at the office.\r\n% One experiment was hitting the same letter over and over again about 200\r\n% times recording the results of how everything shifted.  The other\r\n% experiment was to hit each letter from the initial rotor setting, reset\r\n% the rotor, and hit the button again.  All of this data became crucial\r\n% later to identify a physical double stepping behavior in the actual\r\n% Enigma Machines.\r\n%\r\n% If you're ever in Natick, I'd encourage you to go to the World War II\r\n% museum.  The hours and tour schedule are on the\r\n% <visit website>.  It's far more\r\n% interesting than the mall.\r\n\r\n%% Using MATLAB Enigma\r\n%\r\n% Let's take a quick walk through using MATLAB Engima.  There are two ways\r\n% you can use it, both with and without a user interface.  Let's first use\r\n% the UI.\r\n% \r\n%   launchEnigma\r\n% \r\n% <<enigma1.png>>\r\n%\r\n% Use the gear icon in the upper right-hand corner to configure the\r\n% components and plugboard.\r\n%\r\n% <<enigma2.png>>\r\n% \r\n% <<enigma3.png>>\r\n% \r\n% Use the mouse scroll wheel over the rotor or left-click and drag for the\r\n% initial rotor settings.\r\n%\r\n% <<enigma4.png>>\r\n%\r\n% Type your message using your keyboard or by pushing the letter keys\r\n% on the screen!  The keys and indicators will light up as you type.\r\n%\r\n% <<enigma5.png>>\r\n%\r\n% Now you can <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/?utf8=%E2%9C%93&term=morse+code morse code> that message to your friend.\r\n%\r\n% How about with the command line?\r\n\r\nMyEnigma = enigma;\r\n\r\n%%\r\n% Select the rotors.\r\n\r\nMyEnigma.Rotors = {'V' 'II' 'I'};\r\n\r\n%%\r\n% Set the ring offset.\r\nMyEnigma.RingSettings = [1 11 5];\r\n\r\n%%\r\n% Select the reflector.\r\nMyEnigma.Reflector = 'B';\r\n\r\n%%\r\n% Rotate the rotors to the desired position.\r\nMyEnigma.RotorSettings = 'PBR';\r\n\r\n%%\r\n% Connect the plugboard.\r\nconnectPlug(MyEnigma,'QWERASDFPYC','ZUIOGJKLVHM');\r\n\r\n%%\r\n% Perform the encryption.\r\nencryptedmsg = run(MyEnigma,'THANKYOUFORREADING');\r\ndisp(encryptedmsg)\r\n\r\n%% \r\n% The machine knows its state, so you can see that in the command line\r\n% display.\r\ndisp(MyEnigma)\r\n\r\n%% \r\n% And finally, clear the log to cover your tracks in case your office is\r\n% compromised.\r\n\r\nclearLog(MyEnigma)\r\n\r\n\r\n%% Summary\r\n%\r\n% This was obviously a really fun project for all involved.  In terms of\r\n% software, we demonstrated what can be done with MATLAB Graphics, fully\r\n% utilized the\r\n% <https:\/\/www.mathworks.com\/help\/releases\/R2015b\/matlab\/source-control.html\r\n% integrated Git source control> from within MATLAB, worked collaboratively\r\n% on a short deadline, and demonstrated a good example of an architecture for\r\n% building applications with a user interface.\r\n%\r\n% Of course, we also learned a lot about how these machines work and what\r\n% an engineering marvel they really are!  Thanks again to Kenneth from the\r\n% WWII museum for granting us access to the machines and helping with our\r\n% questions.\r\n%\r\n% For more information on the history and the algorithm implementation in\r\n% MATLAB, check out\r\n% <https:\/\/www.mathworks.com\/company\/newsletters\/articles\/alan-turing-and-his-connections-to-matlab.html\r\n% this entry in Cleve's Corner>.\r\n\r\n%% Comments\r\n% \r\n% Watch the video, give the app a try and let us know what you think\r\n% <https:\/\/blogs.mathworks.com\/pick\/?p=6201#respond here> or leave a\r\n% <https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/51009-enigma#comments\r\n% comment> for the Enigma Team.\r\n%\r\n##### SOURCE END ##### a2e43392c77b43538eec2546dc6e7960\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/Sean\/mainEnigma\/enigma1.png\" onError=\"this.style.display ='none';\" \/><\/div><p>\r\n   \r\n      Sean's pick this week is Enigma by Matt Brauer and the Engima MATLAB Team.\r\n      \r\n   \r\n   Contents\r\n   \r\n      \r\n     ... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2015\/10\/30\/enigma\/\">read more >><\/a><\/p>","protected":false},"author":87,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6201"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/87"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=6201"}],"version-history":[{"count":7,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6201\/revisions"}],"predecessor-version":[{"id":11907,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/6201\/revisions\/11907"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=6201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=6201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=6201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}