<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[The Osmosian Order of Plain English Programmers Welcomes You]]></provider_name><provider_url><![CDATA[http://osmosianplainenglishprogramming.blog]]></provider_url><author_name><![CDATA[gerryrzeppa]]></author_name><author_url><![CDATA[https://osmosianplainenglishprogramming.blog/author/gerryrzeppa/]]></author_url><title><![CDATA[Hiding in Plain&nbsp;Sight]]></title><type><![CDATA[link]]></type><html><![CDATA[<header class="entry-header">
<h1 class="entry-title"></h1>
</header>
<div class="entry-content">
<p>One of these pictures contains a hidden message 83 characters long:</p>
<p><img loading="lazy" class="alignnone size-full wp-image-321124" src="https://cdncontribute.geeksforgeeks.org/wp-content/uploads/cypher-1.png" alt="" width="645" height="331" /></p>
<p>Externally and internally, however, they are both very similar. Externally, they are what you see above. Internally, each of them is just a very long string of characters, where each character corresponds to a pixel in the image. There are just 27 allowed characters (numbers 64 to 90 on the ASCII chart):</p>
<p><span style="color:#00ccff;">@ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z</span></p>
<p>“@” means black, and “Z” means white, with the letters in-between representing increasingly lighter shades of gray. The definition of the image on the left looks like this in our program:</p>
<p><span style="color:#00ccff;">The cipher is a string equal to &#8220;NNNNNOOOOOOOPP&#8230;&#8221;</span></p>
<p>It’s much longer, of course. 82,944 bytes, to be exact. This is the routine we use to draw it on the screen:</p>
<p><span style="color:#00ccff;">To display a cipher in a box (as a picture):</span><br />
<span style="color:#00ccff;"> Put the cipher&#8217;s first into a byte pointer.</span><br />
<span style="color:#00ccff;"> Put the box&#8217;s left-top into a spot.</span><br />
<span style="color:#00ccff;"> Loop.</span><br />
<span style="color:#00ccff;"> If the spot&#8217;s y is the box&#8217;s bottom, break.</span><br />
<span style="color:#00ccff;"> Put the byte pointer&#8217;s target into a byte.</span><br />
<span style="color:#00ccff;"> Convert the byte to a color.</span><br />
<span style="color:#00ccff;"> Draw the spot with the color.</span><br />
<span style="color:#00ccff;"> Add 1 to the byte pointer. If the byte pointer is greater than the cipher&#8217;s last, break.</span><br />
<span style="color:#00ccff;"> Move the spot right 1 pixel.</span><br />
<span style="color:#00ccff;"> If the spot&#8217;s x is the box&#8217;s right,</span><br />
<span style="color:#00ccff;"> put the box&#8217;s left into the spot&#8217;s x; move the spot down 1 pixel; repeat.</span><br />
<span style="color:#00ccff;"> Repeat.</span><br />
<span style="color:#00ccff;"> Refresh the screen.</span></p>
<p>And this is the routine that we use to encode a message into a cipher image:</p>
<p><span style="color:#00ccff;">To encode a message in a cipher given a key:</span><br />
<span style="color:#00ccff;"> Put the message&#8217;s first into a message byte pointer.</span><br />
<span style="color:#00ccff;"> Put the cipher&#8217;s first into a cipher byte pointer.</span><br />
<span style="color:#00ccff;"> Loop.</span><br />
<span style="color:#00ccff;"> If the message byte pointer is greater than the message&#8217;s last, break.</span><br />
<span style="color:#00ccff;"> Add the key to the cipher byte pointer.</span><br />
<span style="color:#00ccff;"> If the cipher byte pointer is greater than the cipher&#8217;s last, break.</span><br />
<span style="color:#00ccff;"> If the message byte pointer&#8217;s target is the space byte,</span><br />
<span style="color:#00ccff;"> put the at-sign byte into the cipher byte pointer&#8217;s target.</span><br />
<span style="color:#00ccff;"> If the message byte pointer&#8217;s target is not the space byte,</span><br />
<span style="color:#00ccff;"> put the message byte pointer&#8217;s target into the cipher byte pointer&#8217;s target.</span><br />
<span style="color:#00ccff;"> Add 1 to the message byte pointer.</span><br />
<span style="color:#00ccff;"> Repeat.</span></p>
<p>We thus replace some of the bytes in the cipher image’s string with the characters of the hidden message. Since the message affects only a very small percentage of the image’s characters, and since the characters in the message come from the same subset of the ASCII chart, and since we choose a “key” that will spread the message as thinly as possible across the entire image, the visual effect is very hard to detect. In this case, there are 83 characters in the message. Can you spot 83 differences in the images above?</p>
<p>To get the message back out, we use this routine:</p>
<p><span style="color:#00ccff;">To decode a cipher into a message given a key:</span><br />
<span style="color:#00ccff;"> Clear the message.</span><br />
<span style="color:#00ccff;"> Put the cipher&#8217;s first into a byte pointer.</span><br />
<span style="color:#00ccff;"> Loop.</span><br />
<span style="color:#00ccff;"> Add the key to the byte pointer.</span><br />
<span style="color:#00ccff;"> If the byte pointer is greater than the cipher&#8217;s last, break.</span><br />
<span style="color:#00ccff;"> If the byte pointer&#8217;s target is the at-sign byte,</span><br />
<span style="color:#00ccff;"> append the space byte to the message; repeat.</span><br />
<span style="color:#00ccff;"> Append the byte pointer&#8217;s target to the message.</span><br />
<span style="color:#00ccff;"> Repeat.</span></p>
<p>So let’s find out what that hidden message says. Here’s the test routine:</p>
<p><span style="color:#00ccff;">To run:</span><br />
<span style="color:#00ccff;"> Start up.</span><br />
<span style="color:#00ccff;"> Clear the screen to the tan color.</span><br />
<span style="color:#00ccff;"> Imagine a box 3 inches by 3 inches in the middle of the screen.</span><br />
<span style="color:#00ccff;"> Move the box left 1-5/8 inches.</span><br />
<span style="color:#00ccff;"> Display the cipher in the box (as a picture).</span><br />
<span style="color:#00ccff;"> Encode the message in the cipher given 997.</span><br />
<span style="color:#00ccff;"> Move the box right 3-1/4 inches.</span><br />
<span style="color:#00ccff;"> Display the cipher in the box (as a picture).</span><br />
<span style="color:#00ccff;"> Decode the cipher into a decoded message given 997.</span><br />
<span style="color:#00ccff;"> Write the decoded message below the box.</span><br />
<span style="color:#00ccff;"> Refresh the screen.</span><br />
<span style="color:#00ccff;"> Wait for the escape key.</span><br />
<span style="color:#00ccff;"> Shut down.</span></p>
<p>Note that, in Plain English, “1-5/8 inches” means “one and five-eighths inches”, not “one <em>minus</em> five eighths inches”. Likewise for “3-1/4”.</p>
<p>Note also that we use 997 for the key because the message is 83 characters long, which is roughly 1/1000 of the 82,944 characters in the image, and 997 is the largest prime less than 1000.</p>
<p>The output on the screen looks like this:</p>
<p><img loading="lazy" class="alignnone size-large wp-image-321157" src="https://cdncontribute.geeksforgeeks.org/wp-content/uploads/cypher-2-1024x819.png" alt="" width="665" height="532" /></p>
<p>If we want the “defects” in the encoded cipher to be less noticeable, we can use a shorter message or a larger picture.</p>
<p>On a personal side note, I must say I’m struck by the quality of the images. After all, we’re using a trivial data structure (a string) and only 27 shades of gray. Who wudda thunk?</p>
</div>
]]></html><thumbnail_url><![CDATA[https://i1.wp.com/cdncontribute.geeksforgeeks.org/wp-content/uploads/cypher-1.png?fit=440%2C330&ssl=1]]></thumbnail_url><thumbnail_width><![CDATA[440]]></thumbnail_width><thumbnail_height><![CDATA[226]]></thumbnail_height></oembed>