Skip to content

Nodejs version8 calling crypto.pbkdf2Sync without digest parameter throwing error #4

Closed
@airicyu

Description

@airicyu

In old version of NodeJS, crypto.pbkdf2Sync method does not mandatory requiring the digest parameter. Since nodejs 6, calling this method without the digest parameter would having a warning. Since nodejs 8, calling this method without the digest parameter would throw error which breaking some existing codes. For forward compatible concern, we should add the digest parameter which is the default value of 'sha1'.

I tested the existing code of opentoken module in Nodejs version6,7,8.
Version 6 is OK. Version 7 is also OK but having a warning. Version 8 would throw error like this:

node .\test\opentoken_test.js
crypto.js:635
throw new TypeError(
^

TypeError: The "digest" argument is required and must not be undefined
at pbkdf2 (crypto.js:635:11)
at Object.exports.pbkdf2Sync (crypto.js:628:10)
at generateKey (...\node-opentoken\lib\ciphersuites.js:69:27)
at decode (...\node-opentoken\lib\token.js:166:23)
at OpenTokenAPI.parseToken (...\node-opentoken\opentoken.js:47:3)
at ...\node-opentoken\test\opentoken_test.js:15:10
at Object. (...\node-opentoken\test\opentoken_test.js:21:2)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)

I found the error throwing code and added the default value digest parameter 'sha1'. And then the test cases are passed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions