Good night,
I am trying to use CS.Hash.createHash(….) to validate the PIN of a CSPro application that uses HTML/JavaScript, but the PIN generates different hash values in CSPro/JavaScript.
Greetings,
CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript
CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript
- Attachments
-
- hash_value.pdf
- (34.78 KiB) Downloaded 377 times
-
- Posts: 1851
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript
The difference you're seeing is because you're adding quotemarks to the text to hash:
let hashedpassword = CS.Hash.createHash({text: '"' + password + '"', type: "PBKDF2_SHA256"});
See here for an example of the differences in hashing the value with and without quotemarks:console.log(CS.Hash.createHash({text: "5781", type: "PBKDF2_SHA256"}));
// 433255dfb3dc637dd1740741e6861381fd8f010f8b49c23a535ccd107d0dd915
console.log(CS.Hash.createHash({text: "\"5781\"", type: "PBKDF2_SHA256"}));
// 99509812eb28458679890d5711b13e6933454df4260f1d125596fd62facdffa5
The first option matches what you are seeing in CSPro logic.// 433255dfb3dc637dd1740741e6861381fd8f010f8b49c23a535ccd107d0dd915
console.log(CS.Hash.createHash({text: "\"5781\"", type: "PBKDF2_SHA256"}));
// 99509812eb28458679890d5711b13e6933454df4260f1d125596fd62facdffa5