Skip to content

Instantly share code, notes, and snippets.

@BorisOsipov
Created May 30, 2023 14:52
Show Gist options
  • Save BorisOsipov/9a0390d79565ac58504e2b29723b3b68 to your computer and use it in GitHub Desktop.
Save BorisOsipov/9a0390d79565ac58504e2b29723b3b68 to your computer and use it in GitHub Desktop.
function generateAuthenticationString(password, salt, challenge) {
const step1 = password + salt;
const step2 = sha256(step1); // SHA256 binary hash
const base64Secret = Buffer.from(step2, 'hex').toString('base64');
const step3 = base64Secret + challenge;
const step4 = sha256(step3); // SHA256 binary hash
const authenticationString = Buffer.from(step4, 'hex').toString('base64');
return authenticationString;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment