详细问题描述
在1.8之后自定义组件模式下调用以下代码会报
Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative;at api request success callback function
const salt = bcrypt.genSaltSync(saltRounds);
var code = bcrypt.hashSync(“aa”,salt)
之后 自行用isaac.js 后解决了该问题
但是在最新更新的 2.2.1版本后bcrypt.hashSync()会变得非常耗时 5s以上
bcrypt 相关源码如下:
bcrypt.hashSync = function(s, salt) {
if (typeof salt === 'undefined')
salt = GENSALT_DEFAULT_LOG2_ROUNDS;
if (typeof salt === 'number')
salt = bcrypt.genSaltSync(salt);
if (typeof s !== 'string' || typeof salt !== 'string')
throw Error("Illegal arguments: "+(typeof s)+', '+(typeof salt));
return _hash(s, salt);
};
bcrypt.genSaltSync = function(rounds, seed_length) {
rounds = rounds || GENSALT_DEFAULT_LOG2_ROUNDS;
if (typeof rounds !== 'number')
throw Error("Illegal arguments: "+(typeof rounds)+", "+(typeof seed_length));
if (rounds < 4)
rounds = 4;
else if (rounds > 31)
rounds = 31;
var salt = [];
salt.push("$2a$");
if (rounds < 10)
salt.push("0");
salt.push(rounds.toString());
salt.push('$');
salt.push(base64_encode(random(BCRYPT_SALT_LEN), BCRYPT_SALT_LEN)); // May throw
return salt.join('');
};
[IDE版本号]
HBuilder X 2.2.1.20190813
[mac版本号]
10.15 Beta (19A526h)
uni-app运行环境说明
云打包后 自定义基座 真机调试都有延迟 Android模拟器有延迟 ios模拟器上没有延迟
[运行端是h5或app或某个小程序?]
h5 正常 app 延迟
2 个回复
pollexstorm
你的问题解决了么
2***@qq.com
Neither WebCryptoAPI nor a crypto module is available. Use bcrypt.setRandomFallback to set an alternative;at api request success callback function,这个问题咋解决的,哪块有说明吗,网上找了挺多的都不好使
l***@gmail.com (作者)
我也没找到解决方法
2020-02-12 18:23