2

I'm using https://github.com/brianc/node-postgres pg module. Apparently I can't consume a Unicode password to connect to the db. From the same location psql with connection parameters goes OK. With Node.js, it gives ne password authentication failed for user. When I check with console.log() I see exactly what I expect. If I change a password to ASCII both in the db and the connection string, everything works well. But I need the old Unicode password to be consumed...

I tried both https://github.com/brianc/node-postgres/wiki/Client

new pg.Client({...password: Código

and

conString = "postgres://...Código@"

I know that both ODBC (Driver={PostgreSQL UNICODE};) and JDBC (;Unicode=true) support UTF in connection string. I find nothing on Node.js pg module UTF support.

Please help.

I saw http://www.connectionstrings.com/postgresql/ and read the documentation on https://github.com/brianc/node-postgres. Please help with the question.

Thank you!

2
  • would github.com/bnoordhuis/node-iconv be helpful?.. Commented Nov 26, 2015 at 10:34
  • @brianc would you please have a look?.. Commented Dec 3, 2016 at 21:10

1 Answer 1

2

Found a bug in /lib/client.js: crypto.createHash('md5').update('�?тфUTF').digest('hex') gives:

a77b17c858d93bf7455211a629df45f8

while the right md5 would be:

a=#select md5('�?тфutf');
               md5
----------------------------------
 6dbfa2a80226f7629e537268b0650898
(1 row)

So crypto.createHash('md5').update('�?тфutf', 'utf-8').digest('hex') gives

6dbfa2a80226f7629e537268b0650898

Following that

The default encoding used by the crypto module is usually 'binary' from another answer

Fixed my utf password problem. So I created PR - maybe soon it won't be a question anymore.

https://github.com/brianc/node-postgres/pull/1178

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.