title: contains and equal condition faling on equal strings, encryption and decryption
body: <p>dear stackoverflow helpers
  I was just testing my skills and learning the same way as i always do when i encountered something strange, searched the web but just couldn'
  t find out what was going wrong.</p>
  
  <p>I was trying to build an encryption program storing its keys in a isostream.
  The first time you can write the key without a condition, however after that you need to put in the old key</p>
  
  <pre><code>        (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("key.txt", FileMode.CreateNew, isoStore))
              {
                  using (StreamWriter writer = new StreamWriter(isoStream))
                  {
                      //keycreation begin
                      Random rnd = new Random();
                      int random1 = rnd.Next(20000, 2000000); //number between 2000 and 2 million
                      stringrandom0 = random1.ToString();
                      char[] chars = "$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&amp;".ToCharArray();
                      Random r = new Random();
                      int i = r.Next(chars.Length);
                      int q = r.Next(chars.Length);
                      int w = r.Next(chars.Length);
                      stringrandom1 = chars[i].ToString();
                      stringrandom2 = chars[q].ToString();
                      stringrandom3 = chars[w].ToString();
                      int random2 = rnd.Next(20000, 2000000); //number between 2000 and 2 million
                      stringrandom4 = random2.ToString();
                      key = stringrandom0 + stringrandom1 + stringrandom2 + stringrandom3 + stringrandom4;
                      textBox2.Text = "Creation &amp; Encryption succesful finished your key = " + key + " do not lose this key!";
                      //key will look like this: letters, numbers, letters
                      //key creation end
  
                      writer.WriteLine(key);
  
                      File.Create(@"C:\Users\Legion\Desktop\encryption\text\" + fileName1).Close();
                      //Console.WriteLine("You have written to the file.");
                  }
              }
  </code></pre>
  
  <p>So it gave me a key: when things didn't work out i let it display in a textbox to be sure. I recieve it this way.</p>
  
  <pre><code>      IsolatedStorageFile isoStore = IsolatedStorageFile.GetStore(IsolatedStorageScope.User | IsolatedStorageScope.Assembly, null, null);
          using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("key.txt", FileMode.Open, isoStore))
          {
              using (StreamReader reader = new StreamReader(isoStream))
              {
                  keyentered = textBox4.Text;
                  checkkey = (reader.ReadToEnd());
                  textBox1.Text = checkkey;
                  textBox3.Text = keyentered;
              }
          }
  </code></pre>
  
  <p>as you can see the code i enter is set to keyenter, i entered this: 156216*ek316677.</p>
  
  <p>Checkkey reads the written piece, and ofcourse to check, i put it to a textbox to and it displayed this: (exactly without spaces) 156216*ek316677.</p>
  
  <p>Comparison
  156216*ek316677.
  156216*ek316677.</p>
  
  <p>So this is the check code</p>
  
  <pre><code>if (isoStore.FileExists("key.txt"))
          {
               using (IsolatedStorageFileStream isoStream = new IsolatedStorageFileStream("key.txt", FileMode.Open, isoStore))
              {
                  if (keyentered.Contains(checkkey) || checkkey == keyentered)
                  {
                      using (StreamWriter writer = new StreamWriter(isoStream))
                      {
                          //keycreation begin
                          Random rnd = new Random();
                          int random1 = rnd.Next(20000, 2000000); //number between 2000 and 2 million
                          stringrandom0 = random1.ToString();
                          char[] chars = "$%#@!*abcdefghijklmnopqrstuvwxyz1234567890?;:ABCDEFGHIJKLMNOPQRSTUVWXYZ^&amp;".ToCharArray();
                          Random r = new Random();
                          int i = r.Next(chars.Length);
                          int q = r.Next(chars.Length);
                          int w = r.Next(chars.Length);
                          stringrandom1 = chars[i].ToString();
                          stringrandom2 = chars[q].ToString();
                          stringrandom3 = chars[w].ToString();
                          int random2 = rnd.Next(20000, 2000000); //number between 2000 and 2 million
                          stringrandom4 = random2.ToString();
                          key = stringrandom0 + stringrandom1 + stringrandom2 + stringrandom3 + stringrandom4;
                          textBox2.Text = "Creation &amp; Encryption succesful finished your key = " + key + " do not lose this key!";
                          //key will look like this: letters, numbers, letters
                          //key creation end
  
                          writer.WriteLine(key);
  
                          File.Create(@"C:\Users\Legion\Desktop\encryption\text\" + fileName1).Close();
                          //Console.WriteLine("You have written to the file.");
                      }
                  }
                  else
                  {
                      textBox2.Text = "invalid key entered!";
                  }
              }
          }
  </code></pre>
  
  <p>the problem is that it keeps saying invalid key entered, while they are exactly equal, so why does the if condition fails?
  I tried a contains to but it fails exactly the same way.</p>
  
  <p>Thanks for any help i might get.
  Cheers godarcher, hobyist and nerd. :D</p>