Page 1 of 1
CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript
Posted: October 4th, 2024, 10:59 pm
by dduarte05
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,
Re: CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript
Posted: October 7th, 2024, 9:49 am
by Gregory Martin
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.
Re: CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript
Posted: October 8th, 2024, 10:38 am
by dduarte05
Thank you Greg.