title: How do I encrypt passwords with PostgreSQL?
body: <p>I have some problems with encoding passwords,how can I do it. Type of encoding md5</p>
  
  <pre><code>digest(data text, type text) returns bytea;
  CREATE OR REPLACE FUNCTION md(bytea) returns text AS $$
      SELECT encode(digest($1, 'sha1'), 'md5')
  $$ LANGUAGE SQL STRICT IMMUTABLE;
  
  INSERT INTO "login"(login, password, employee_id)
  VALUES ( 'email',crypt('password', md('md5')), 1);
  </code></pre>
  
  <p><em><strong></em>***<em></strong> Error <strong></em>**<em>*</em></strong></p>
  
  <pre><code>ERROR: syntax error at or near "digest"
  SQL state: 42601
  Character: 1
  </code></pre>