javascript - scrypt.js 失败,N 大于 2^14

标签 javascript hash cryptography scrypt

这行得通

var scrypt = scrypt_module_factory();
var pwh=scrypt.crypto_scrypt(scrypt.encode_utf8("pleaseletmein"),
            scrypt.encode_utf8("SodiumChloride"),
            Math.pow(2,14), 8, 1, 224);

失败

var scrypt = scrypt_module_factory();
var pwh=scrypt.crypto_scrypt(scrypt.encode_utf8("pleaseletmein"),
            scrypt.encode_utf8("SodiumChloride"),
            Math.pow(2,15), 8, 1, 224);

区别在于 N 参数是 2^15 而不是 2^14

有什么想法吗?

在Firebug控制台失败如下

uncaught exception: abort() at 
wa@http://localhost/keybase/javascript/scrypt.js:10126:9      
ua@http://localhost/keybase/javascript/scrypt.js:132:9 
nc@http://localhost/keybase/javascript/scrypt.js:1266:9 
bL@http://localhost/keybase/javascript/scrypt.js:4164:33    
bu@http://localhost/keybase/javascript/scrypt.js:2168:33  
crypto_scrypt@http://localhost/keybase/javascript/scrypt.js:10263:1  
get_salt/<.success@http://localhost/keybase/javascript/main.js:91:1  
jQuery.Callbacks/fire@http://code.jquery.com/jquery-latest.js:3119:1  
jQuery.Callbacks/self.fireWith@http://code.jquery.com/jquery- 
latest.js:3231:7 
done@http://code.jquery.com/jquery-latest.js:9275:67 
.send/callback@http://code.jquery.com/jquery-latest.js:9685:8   
.send@http://code.jquery.com/jquery-latest.js:9691:7   
.ajax@http://code.jquery.com/jquery-latest.js:9176:5  
get_salt@http://localhost/keybase/javascript/main.js:95:9  
@http://localhost/keybase/javascript/main.js:58:9  
jQuery.event.dispatch@http://code.jquery.com/jquery-latest.js:4641:1  
jQuery.event.add/elemData.handle@http://code.jquery.com/jquery-
latest.js:4309:1

最佳答案

 var scrypt = scrypt_module_factory(67108864);

解决了这个问题。感谢上面的 Anton Samsonov。这是一个内存问题。没有参数的初始化默认为 32mb。如上初始化将内存使用设置为 64mb。

关于javascript - scrypt.js 失败,N 大于 2^14,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29268935/

相关文章:

ruby-on-rails - 在 Ruby on Rails 中将数组/哈希转换为 YAML

mysql - 使用散列密码进行身份验证?

java - Java BouncyCaSTLe 中的确定性 AES-CTR?

javascript - 内部错误 : Metro Bundler has encountered an internal error [Duplicate Module]

javascript - Angular Marked 和 Inappbrowser 在系统浏览器中打开所有链接

Python方式进行crc32b

version-control - 管理加密 key 的好方法?

cryptography - react 原生 + 加密 : How to generate HMAC in React-Native?

javascript - 了解 JavaScript 原型(prototype)

javascript - 通过网页修改本地文件