title: String Length Not Equal To String Data Unity C#
body: <p>I got a strange problem in here.
  I have two string to compare. </p>
  
  <p>Lets call it :</p>
  
  <p><strong>String "A" and String "B".</strong></p>
  
  <p>Both of string have a same data</p>
  
  <p><strong>"A" : "1234" and "B" : "1234"</strong></p>
  
  <p>But when compare they didn't <em>same or not equal</em>.</p>
  
  <p>I have try to <strong>trim</strong> both of string. But the result still not equal.</p>
  
  <p>Then i try to check the string length. </p>
  
  <p><strong>"A" contain 4, but "B" contain 16.</strong></p>
  
  <p>So it is mean that </p>
  
  <p><strong>string "A" has length 4 and string "B" has length 16.</strong></p>
  
  <p>How it can be like this ?</p>
  
  <p>So now i cannot compare it.</p>
  
  <p>For note. <strong>String "B"</strong> data is a decrypt data from database. But the length became 16.</p>
  
  <p>How i can solve this ? or return string "B" to normal.</p>
  
  <p>Thank You</p>
  
  <p>Edit :</p>
  
  <p>I put the screenshot try see this</p>
  
  <p><a href="https://i.stack.imgur.com/d6ldw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d6ldw.png" alt="enter image description here"></a></p>
  
  <p><strong>And this is the code i use :</strong></p>
  
  <pre><code>if (Input_PIN.text.Length &gt;= 4)
          {
              Debug.Log("A Text : " + Input_PIN.text);
              Debug.Log("A Lenght : " + Input_PIN.text.Length);
              Debug.Log("B Text : " + user_account_detail.Pin);
              Debug.Log("B Lenght : " + user_account_detail.Pin.Length);
  
              if (Input_PIN.text.Trim() == user_account_detail.Pin.Trim())
              {
                  UnityEngine.SceneManagement.SceneManager.LoadScene("scene_foundation");
              }
              else
              {
                  UtilityScript.GetComponent&lt;utility&gt;().MessageBox_Pin_Wrong();
                  Input_PIN.text = "";
              }
  
          }
  </code></pre>
  
  <p><strong>And this is the decrpyt code i use for string "B" :</strong></p>
  
  <pre><code>public static string Decrypt(string prm_text_to_decrypt, string prm_key, string prm_iv)
      {
  
          var sEncryptedString = prm_text_to_decrypt;
  
          var rj = new RijndaelManaged()
          {
              Padding = PaddingMode.PKCS7,
              Mode = CipherMode.CBC,
              KeySize = 256,
              BlockSize = 128,
          };
  
          var key = Convert.FromBase64String(prm_key);
          var IV = Convert.FromBase64String(prm_iv);
  
          var decryptor = rj.CreateDecryptor(key, IV);
  
          var sEncrypted = Convert.FromBase64String(sEncryptedString);
  
          var fromEncrypt = new byte[sEncrypted.Length];
  
          var msDecrypt = new MemoryStream(sEncrypted);
          var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read);
  
          csDecrypt.Read(fromEncrypt, 0, fromEncrypt.Length);
  
          return (Encoding.ASCII.GetString(fromEncrypt));
      }
  </code></pre>