Note that there are some explanatory texts on larger screens.

plurals
  1. POEncrypting and decrypting part of the ASCII table
    primarykey
    data
    text
    <p>I have made small encryption program that uses to keys rot7 and rot13. Everything works fine except two 6 letters uvwxyz.</p> <p>If I type ABCDEFGHIJKLMNOPQRSTUVWXYZ it encrypts and decrypts no problem. However, if I enter the same in lower case letters then uvwxyz do not work. </p> <p>Having said this, I have allowed all the writable characters within the ascii table as the valid range as follows:</p> <pre><code>// allow all writable characters from 32 to 255 if ((str[i] &gt;= 32 ) &amp;&amp; (str[i] &lt;=255)) { str[i] -= key; } </code></pre> <p>Here is the process of encryption:</p> <pre><code> cout &lt;&lt; endl; cout &lt;&lt; "Encrypting process started " &lt;&lt; endl &lt;&lt; endl; cout &lt;&lt; "--------------------------- " &lt;&lt; endl; //get the string length int i = 0; int length = str.length(); int key = rot13 ; int k = 5; int multiple = 0; int count = 0; cout &lt;&lt; "the text to encrypt is: " &lt;&lt; str &lt;&lt; endl; cout &lt;&lt; "text length is: " &lt;&lt; length &lt;&lt; endl; cout &lt;&lt; "using rot13"&lt;&lt;endl; cout &lt;&lt;"---------------------------" &lt;&lt; endl; cout &lt;&lt; "using rot13" &lt;&lt; endl; //traverse the string for(i = 0; i &lt; length; i++) { count ++; cout &lt;&lt; left; //if it is a multiple of 5 not the first character change the key if((multiple = (( i % 5 ) == 0)) &amp;&amp; (count != 1) &amp;&amp; (key == rot13)){ key = rot7; } //if it is a multiple of 5 not the first character change the key else if((multiple = (( i % 5 ) == 0)) &amp;&amp; (count != 1) &amp;&amp; (key == rot7) ) { key = rot13; } // Capital letters are 65 to 90 (a - z) if ((str[i] &gt;= 32) &amp;&amp; (str[i] &lt;= 255)) { str[i] += key; } } return str; </code></pre> <p>How is it possible that the capital letters work and not the lower case if I have allowed this range? Can it be because of something else? I have added these captures with what happens step by step... hopefully this helps</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload