Created
March 16, 2019 17:09
-
-
Save bantic/0e053e4c2c73810f6602d37df1546b39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assume we have a hash function called "hash" | |
// this is the array of already-stored data | |
let data = [{ | |
url: 'google.com', | |
salt: 'asdf1234', | |
hashed_pw: '134hsfdo' | |
}, { | |
url: 'cnn.com', | |
salt: '123489asdf', | |
hashed_pw: '14haef135' | |
}]; | |
function check_password(password) { | |
let matched_urls = []; | |
for (let datum of data) { | |
if (hash(`${password}${datum.salt}`) === datum.hashed_pw) { | |
matched_urls.push(datum.url); // this is a match! | |
} | |
} | |
return matched_urls; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment