Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash result is different from scrypt library. #5

Closed
novemberde opened this issue Jan 25, 2019 · 4 comments
Closed

Hash result is different from scrypt library. #5

novemberde opened this issue Jan 25, 2019 · 4 comments
Assignees

Comments

@novemberde
Copy link

I'm trying to apply this library, but there's an problem.

Compare to other libraries, hash result is totally different.

Here's example code for verification.

const scrypt = require('scrypt');
const jsScrypt = require('js-scrypt');
const scryptsy = require('scryptsy');
const scryptJs = require('scrypt-js');

const salt = 'salt';
const key = 'this is a key';

const N = 16;
const r = 1;
const p = 1;
const dkLen = 64;
const scryptResult = scrypt.hashSync(key, { "N": 16, "r": 1, "p": 1 }, 64, salt);
const jsscryptResult = jsScrypt.hashSync(key, { "N": 16, "r": 1, "p": 1 }, 64, salt);
const scryptsyResult = scryptsy(key, salt, 16,1,1,64);




scryptJs(Buffer.from(key), Buffer.from(salt), N, r, p, dkLen, function (error, progress, key) {
  if (error) {
    console.log("Error: " + error);

  } else if (key) {
    console.log("scryptJsResult: " + Buffer.from(key, 'hex').toString('base64'));
  }
});

console.log('scryptResult: ' + scryptResult.toString('base64'));
console.log('jsscryptResult: ' + jsscryptResult.toString('base64'));
console.log('scryptsyResult: ' + scryptsyResult.toString('base64'));

// Results
scryptJsResult: /TKDucU/c6nSRo6CABG8vwVnK6MeQGs75y1iFlG9Le/sjJ9bQEAEL+Wwvt8zhhZ7Io2Yb8pzQJcnVlV5V6juaQ==
scryptResult: /TKDucU/c6nSRo6CABG8vwVnK6MeQGs75y1iFlG9Le/sjJ9bQEAEL+Wwvt8zhhZ7Io2Yb8pzQJcnVlV5V6juaQ==
jsscryptResult: 5zaU49mSsd8JzgoUKimk+ci9QjyPFq8pLz0AN5O3PVqQtWgQWZHnHzCW7Fk7Y0NeP3gUW98PKaCcPC65udtFbw==
scryptsyResult: /TKDucU/c6nSRo6CABG8vwVnK6MeQGs75y1iFlG9Le/sjJ9bQEAEL+Wwvt8zhhZ7Io2Yb8pzQJcnVlV5V6juaQ==

Only this library returns a different result.

Are there any option to fix this situation?

I'm looking forward to your answer.

Thank you.

@tracker1
Copy link
Owner

tracker1 commented Feb 1, 2019

I didn't write the underlying js-script, it was copied from an asm compiled version about 6 years ago... so I cannot really comment on that aspect, all I did at that time was write wrappers so that I could at least run a few instances in the background in node via a pool of connected workers.

I should probably just deprecate the package in npm and point to one of the other versions... IIRC, when I wrote it, my results were matching a .Net implementation...

Do you have one you would recommend over the others?

@tracker1 tracker1 self-assigned this Feb 1, 2019
@tracker1 tracker1 pinned this issue Feb 1, 2019
@tracker1
Copy link
Owner

tracker1 commented Feb 1, 2019

Aside, I don't know that I should fix it.. if anyone is using this library currently, I could maybe bump the full version with a NOTE and make this just a wrapper against one of the other libraries you're referencing.

@tracker1 tracker1 closed this as completed Feb 1, 2019
@tracker1 tracker1 reopened this Feb 1, 2019
@tracker1
Copy link
Owner

tracker1 commented Feb 1, 2019

Looks like the upstream version I used in my copy had an incompatibility with the current one...

https://github.com/tonyg/js-scrypt/commits/master/browser/scrypt.js
https://github.com/tonyg/js-scrypt/

Again, more than open to suggestions on a library to wrap around the same interface... though, should also consider the newer worker in node 11.7 as well as a Promise based interface.

@novemberde
Copy link
Author

@tracker1 Thank you for your answer.

I found the difference among that libraries. Each library has different function parameter.
Actually, I'd aliased js-scrypt instead of scrypt for making a bundle using webpack, so I found it returns different hash result.

Now, I include 'scrypt' on webpack bundling, it works well!
All is fine.

Thank you again :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants