title: Is SHA256 considered insecure?- SonarQube Quality Gate - How can I fix it?
body: <p>I have below piece of code</p>
  <pre><code>        private static string sensitiveKey = &quot;&lt;REPLACE_WITH_KEY&gt;&quot;  
  
          public static string Encrypt(string input)
          {
              // Get the bytes of the string
              byte[] passwordBytes = Encoding.UTF8.GetBytes(sensitiveKey);
              // Hash the password with SHA256
              passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
              byte[] bytesEncrypted = EncryptStringToBytes_Aes(input, passwordBytes);
              string result = Convert.ToBase64String(bytesEncrypted);
              return result;
          }
  </code></pre>
  <p>SonarQube says</p>
  <blockquote>
  <p>Cryptographic hash functions are used to uniquely identify information without storing their original form. When not done properly, an attacker can steal the original information by guessing it (ex: with a rainbow table), or replace the original data with another one having the same hash.</p>
  </blockquote>
  <p>Also</p>
  <blockquote>
  <p>use only hashing algorithms which are currently known to be strong. Avoid using algorithms like <strong>MD5</strong> and <strong>SHA1</strong> completely in security contexts.</p>
  </blockquote>
  <p>So question is, How can I improve my code so that it can be secure?</p>
  <p>Any samples out thr?</p>