title: How to Generate SCRAM-SHA-256 to Create Postgres 13 User
body: <p>I want to create a Postgres user with the CREATE USER command and an already hashed digest for the password.  After much searching, I thought it was only possible with MD5 until I found <a href="https://subscription.packtpub.com/book/big_data_and_business_intelligence/9781789537581/1/ch01lvl1sec18/changing-your-password-securely" rel="noreferrer">this</a> link.  I've verified that works like so:</p>
  <pre><code>CREATE USER test_user WITH LOGIN PASSWORD 'SCRAM-SHA-256$4096:H45+UIZiJUcEXrB9SHlv5Q==$I0mc87UotsrnezRKv9Ijqn/zjWMGPVdy1zHPARAGfVs=:nSjwT9LGDmAsMo+GqbmC2X/9LMgowTQBjUQsl45gZzA=';
  </code></pre>
  <p>I can then log into that user with the password, which the article doesn't necessarily say but it's &quot;postgres&quot;.  Now that I know it's possible, how using .NET 5 can I generate a scram-sha-256 digest that Postgres 13 will accept?  I've seen other Postgres articles using the outdated MD5 hash where the username is concatenated with the password before hashing.  Does that need to happen with the new scram-sha-256 as well?  I couldn't find much information on this topic anywhere.</p>