节点postgres UTF密码错误
我正在使用https://github.com/brianc/node-postgres pg
模块。 显然,我不能使用Unicode密码连接到数据库。 从相同的位置psql
连接参数OK。 使用Node.js,它会使password authentication failed for user
。 当我检查与console.log()
我确切地看到我的期望。 如果我在数据库和连接string中将密码更改为ASCII,则一切正常。 但我需要旧的Unicode密码被消耗…
我尝试了https://github.com/brianc/node-postgres/wiki/Client
new pg.Client({...password: Código
和
conString = "postgres://...Código@"
我知道ODBC( Driver={PostgreSQL UNICODE};
)和JDBC( ;Unicode=true
)在连接string中都支持UTF。 我没有发现任何关于Node.js pg
模块的UTF支持。
请帮忙。
我看到了http://www.connectionstrings.com/postgresql/并阅读了https://github.com/brianc/node-postgres上的文档。 请帮助这个问题。
谢谢!
在/lib/client.js
发现一个bug: crypto.createHash('md5').update('утфUTF').digest('hex')
给出:
a77b17c858d93bf7455211a629df45f8
而正确的md5将是:
a=#select md5('утфutf'); md5 ---------------------------------- 6dbfa2a80226f7629e537268b0650898 (1 row)
所以crypto.createHash('md5').update('утфutf', 'utf-8').digest('hex')
给出
6dbfa2a80226f7629e537268b0650898
跟随那个
encryption模块使用的默认编码通常是来自另一个答案的 “二进制”
修正了我的utf密码问题。 所以我创build了公关 – 也许很快就不会是一个问题了。