Created
May 1, 2021 14:39
-
-
Save zapalote/0d9a0dbeef867f6df51552ad9e607ca6 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
// decode credentials upon receiving them from store | |
function decodeCredentials(crd){ | |
// decrypt it first | |
const dec = CryptoJS.AES.decrypt(crd, saltCredentials).toString(CryptoJS.enc.Utf8); | |
// extract the creds length and pepper step | |
const len = dec.charCodeAt(0) - 96; | |
const step = dec.charCodeAt(1) - 96; | |
let i = 0, j = 2, d = []; | |
// extract the pepper from the salt | |
while( i < len ){ | |
d[i++] = dec[j]; | |
j += step; | |
} | |
// return the json object | |
return JSON.parse(d.join('')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment