title: Error using PostgreSQL digest function trying to check password
body: <p>I'm using PostgreSQL 9.5 and trying to comprehend how to store passwords with digest and crypt functions within the pgcrypto module.
  I have a table like this:</p>
  <pre><code>CREATE TABLE &quot;usuarios&quot; (
  &quot;id&quot; integer NOT NULL ,
  &quot;password&quot; varchar(120),
  CONSTRAINT usuarios_pk PRIMARY KEY (&quot;id&quot;)
  );
  </code></pre>
  <p>I succesfully saved the first row with this query:</p>
  <pre><code>INSERT INTO public.usuarios VALUES (DEFAULT,digest('somesalt' || 'mypass','sha256'));
  </code></pre>
  <p>I took the idea of the global salt and the digest using the sha256 algorithm reading this <a href="https://stackoverflow.com/questions/2647158/how-can-i-hash-passwords-in-postgresql">post</a> and the official <a href="http://www.postgresql.org/docs/9.5/static/pgcrypto.html" rel="nofollow noreferrer">documentation</a> following the example using crypt()</p>
  <p>My problem is, when I try to compare the password in pgAdmin with the following query:</p>
  <pre><code>SELECT (usuarios.password = digest('somesalt' || 'mypass','sha256')) AS Match FROM usuarios; 
  </code></pre>
  <p>I get an error mismatching password type( varchar) and digest type (bytea). I have been looking around for a workaround or how the cast would be but cannot find it or, maybe cannot understand what's under my nose.
  Any help?</p>