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
-
dduarte05
- Posts: 14
- Joined: July 8th, 2014, 12:47 pm
- Location: República Dominicana
CS.Hash.createHash(….) generates different hash values in CSPro/JavaScript
You do not have the required permissions to view the files attached to this post.
-
Gregory Martin
- Posts: 1947
- 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
-
dduarte05
- Posts: 14
- Joined: July 8th, 2014, 12:47 pm
- Location: República Dominicana