anchor.diff:          Result -> Result
       end,
       UserSalt = proplists:get_value(<<"salt">>, User, <<>>),
  -    PasswordHash = couch_util:encodeBase64(crypto:sha(<<UserSalt/binary, Password/binary>>)),
  +    PasswordHash = hash_password(Password, UserSalt),
       case proplists:get_value(<<"password_sha">>, User, nil) of
           ExpectedHash when ExpectedHash == PasswordHash ->
               Secret = ?l2b(couch_config:get("couch_httpd_auth", "secret", nil)),
  
positive.code:     AuthorizationHeader = header_value(Req, "Authorization"),
      case AuthorizationHeader of
      "Basic " ++ Base64Value ->
          io:format("~n~nBase64Value: '~p'~n~n", [Base64Value]),
          case string:tokens(?b2l(couch_util:decodeBase64(Base64Value)),":") of
          [User, Pass] ->
              {User, Pass};
  
negative.code:         couch_util:encodeBase64Url(SessionData ++ ":" ++ ?b2l(Hash)),
          [{path, "/"}, {http_only, true}]). % TODO add {secure, true} when SSL is detected
  
  hash_password(Password, Salt) ->
      ?l2b(couch_util:to_hex(crypto:sha(<<Password/binary, Salt/binary>>))).
  
  % Login handler with user db
  handle_login_req(#httpd{method='POST', mochi_req=MochiReq}=Req, #db{}=Db) ->
      ReqBody = MochiReq:recv_body(),
  