CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript

Discussions about CSEntry
Post Reply
dduarte05
Posts: 13
Joined: July 8th, 2014, 12:47 pm
Location: República Dominicana

CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript

Post 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,
Attachments
hash_value.pdf
(34.78 KiB) Downloaded 377 times
Gregory Martin
Posts: 1851
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript

Post 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.
dduarte05
Posts: 13
Joined: July 8th, 2014, 12:47 pm
Location: República Dominicana

Re: CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript

Post by dduarte05 »

Thank you Greg.
Post Reply