2016-01-11 14 views

回答

1

source code of Meteor告诉我们密码究竟是如何散列:

// Use bcrypt to hash the password for storage in the database. 
// `password` can be a string (in which case it will be run through 
// SHA256 before bcrypt) or an object with properties `digest` and 
// `algorithm` (in which case we bcrypt `password.digest`). 
// 
var hashPassword = function (password) { 
    password = getPasswordString(password); 
    return bcryptHash(password, Accounts._bcryptRounds); 
}; 

而且也:

Accounts._bcryptRounds = 10; 

因此,你可以简单地通过首先将SHA256创建一个新的哈希值,然后10轮的bcrypt在原始密码字符串上。

如果你只有一个或两个密码进行修改,并希望由专人对其进行更新,这里有一些在线工具来做到这一点:

Online SHA-256 calculator

Online bcrypt calculator

您创建了一个后新的哈希,只需使用Mongo控制台更新它:

db.users.update({"emails.address": "[email protected]"}, {$set: {"services.password.bcrypt": "$2a$10$u/4JV2MrAKb8Jk9yRHDIL.yGn5SQOInFunvUwEnDv5uJgMkWNe08K"}}); 
+0

这是一个非常酷的解决方案。谢谢@Jimmi – BassT

0

我最终增加了一个Meteor method这做我所需要的。

但是我不太喜欢它的想法,并认为应该有更好的方法。

相关问题