-
Notifications
You must be signed in to change notification settings - Fork 20
/
index.html
79 lines (76 loc) · 3.12 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Online PKCE Generator Tool</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.2/css/bulma.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.min.js"></script>
<script async defer src="https://buttons.github.io/buttons.js"></script>
<script>
function generateCodeVerifier() {
var rand = new Uint8Array(32);
crypto.getRandomValues(rand);
var code_verifier = base64URL(new CryptoJS.lib.WordArray.init(rand));
document.getElementById("code_verifier").value = code_verifier
}
function generateCodeChallenge(code_verifier) {
return code_challenge = base64URL(CryptoJS.SHA256(code_verifier))
}
function base64URL(string) {
return string.toString(CryptoJS.enc.Base64).replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
}
function submit() {
var code_verifier = document.getElementById("code_verifier").value
var code_challenge = generateCodeChallenge(code_verifier)
document.getElementById("code_challenge").value = code_challenge
}
</script>
</head>
<body>
<section class="hero is-primary">
<div class="hero-body">
<div class="container">
<h1 class="title">
Online PKCE Generator Tool
</h1>
<p class="subtitle">
An online tool to generate <strong>code verifier</strong> and <strong>code challenge</strong> for OAuth with PKCE.
</p>
</div>
</div>
</section>
<section class="section">
<div class="container">
<div class="box">
<div class="field">
<label class="label">Code Verifier</label>
<p>This tool serves as an example implementation or for sending manual requests. Never reuse code verifier values.</p>
<div class="control">
<textarea class="textarea" id="code_verifier" type="text" placeholder="OAuth PKCE Code Verifier" rows="2"></textarea>
</div>
</div>
<div class="field">
<label class="label">Code Challenge</label>
<div class="control">
<input class="input is-static" id="code_challenge" value="(To be generated)" readonly>
</div>
</div>
<div class="level">
<div class="level-left">
<div class="level-item"><button class="button is-link" onclick="submit()">Generate Code Challenge</button></div>
<div class="level-item"><button class="button is-text" onclick="generateCodeVerifier()">Generate Code Verifier</button></div>
</div>
</div>
</div>
</div>
</section>
<section class="section">
<div class="container">
<a class="github-button" href="https://github.com/tonyxu-io/pkce-generator" data-size="large" data-show-count="true" aria-label="Star tonyxu-io/pkce-generator on GitHub">Star</a>
<p>Reference: <a href="https://tools.ietf.org/html/rfc7636">rfc-7636</a></p>
<p>Author: <a href="https://tonyxu.io">Tony Xu</a></p>
</div>
</section>
</body>
</html>