Created
January 20, 2018 00:39
-
-
Save saltukalakus/8ae039c531450016178f703089aeeda9 to your computer and use it in GitHub Desktop.
PKCE_codes.js
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
var crypto = require('crypto'); | |
function base64URLEncode(str) { | |
return str.toString('base64') | |
.replace(/\+/g, '-') | |
.replace(/\//g, '_') | |
.replace(/=/g, ''); | |
} | |
var verifier = base64URLEncode(crypto.randomBytes(32)); | |
function sha256(buffer) { | |
return crypto.createHash('sha256').update(buffer).digest(); | |
} | |
var challenge = base64URLEncode(sha256(verifier)); | |
console.log("verifier :" + verifier); | |
console.log("challenge :" + challenge); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment