title: Encrypt a file using one's complement
body: <p>I have used C++ file streams to encrypt a file. In this, every character read is one's complemented and written into the output file:</p>
  
  <pre><code>ifstream input("Normal file");
  ofstream output("encrypted file");
  char ch;
  while (input &gt;&gt; ch)
  {
    ch = ~ch;
    output &lt;&lt; ch;
  }
  </code></pre>
  
  <p>I used the same program to recover <strong>normal file</strong> from <strong>encrypted file</strong>. However, I found that the unencrypted file did not have any blank spaces or return marks. So, I changed the while part to:</p>
  
  <pre><code>while (input &gt;&gt; ch)
  {
    ch = isspace(ch) ? ch : ~ch;
    output &lt;&lt; ch;
  }
  </code></pre>
  
  <p>Till the results are not what I expected. Where did I go wrong?</p>