-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathform.html
47 lines (41 loc) · 2.18 KB
/
form.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
<!DOCTYPE HTML>
<html lang=en>
<title>a simple TOTP generator</title>
<meta charset=utf-8>
<meta name=viewport content=width=device-width,initial-scale=1>
<style>
#ERROR { font-weight: bold; color: red; display: block; height: 1em }
#KEY:invalid { background-color: red; color: pink }
#CODE { font: 250% monospace; letter-spacing: .15em; user-select: all }
#CODE::after { all: initial; content: ' ' attr(title); color: red; pointer-events: none }
#CODE[title^="copied!"]::after { color: green }
input, button { font: inherit }
#USER, #KEY { box-sizing: border-box; width: 100%; max-width: 25em }
button { max-width: max-content }
#ADD { display: none }
.popup *, .popup ~ * { display: none }
.popup #USER { all: revert; display: block; margin: .5em 0 }
.popup #CODE { all: revert; user-select: all }
.popup #CODE::after { font-size: 80% }
.popup #ADD { display: inline; float: right }
</style>
<form id=FORM>
<label for=USER>User</label><br>
<input id=USER size=27 autocomplete=username>
<p>
<label for=KEY>Shared Key</label>
<label><input type=checkbox id=SHOW>show</label><br>
<input id=KEY size=27 autocomplete=current-password type=password pattern="[a-zA-Z2-7\s]+">
<output for=KEY id=ERROR></output>
</p>
<output for=KEY id=CODE>XXXXXX</output>
<a id=ADD href target=_blank>add key</a>
<p><button type=button id=GENERATE>Generate TOTP (and copy it to clipboard)</button>
<p><button>Save the key (with the browser's password manager)</button>
</form>
<p>The TOTP shared key should be in base32 format, e.g. <code>TK7P33KPE527ZTOX</code> (github) or <code>opid zgaw quda ip7q tj3z izo7 oemp t7dm</code> (google).
<p>The <q>User</q> field is not used for computing the TOTP; its only purpose is to act as a label for the password manager.
<p>If the <q>Save..</q> button does not pop up the <q>Save login/password</q> dialog, look for a key-like icon in the address bar or password input box and click on it.
<p>Saving keys will not work if you have disabled <q>Ask to save logins and passwords for websites</q> in <code>about:preferences#privacy</code> in firefox, or if you're accessing this page via <code>file://</code> in chrome.
<script src=form.js></script>
<script src=totp.js></script>