title: Generate ASP.Net Membership password hash in pure T-SQL
body: <p>I'm attempting to create a pure t-sql representation of the default SHA-1 password hashing in the ASP.Net Membership system. Ideally, what I would get would be this:</p>
  
  <pre><code>UserName           Password              GeneratedPassword
  cbehrens           34098kw4D+FKJ==       34098kw4D+FKJ==
  </code></pre>
  
  <p>Note: that's bogus base-64 text there. I've got base64_encode and decode functions that round-trip correctly. Here's my attempt, which doesn't work:</p>
  
  <pre><code>SELECT UserName, Password, dbo.base64_encode(HASHBYTES('SHA1', dbo.base64_decode(PasswordSalt) +  'test')) As TestPassword FROM aspnet_Users U JOIN aspnet_membership M ON U.UserID = M.UserID
  </code></pre>
  
  <p>I've tried a number of variations on the theme, to no avail. I need to do this in pure T-Sql; involving a console app or something like that will double the work.</p>
  
  <p>So if anyone can supply what precisely the syntax should be to duplicate that password from the ASP.Net membership stuff, I would greatly appreciate it.</p>