-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathespkey.html
More file actions
225 lines (190 loc) · 5.76 KB
/
Copy pathespkey.html
File metadata and controls
225 lines (190 loc) · 5.76 KB
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
<!doctype html>
<html class="no-js">
<head>
<meta charset="utf-8"/>
<title>ESPKey</title>
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="description" content="ESPKey - An ESPHome encryption key generator" />
<meta name="keywords" content="ESPKey,ESPHome,ESP32,Ehryk" />
<meta name="author" content="Eric Menze" />
<meta property="og:url" content="https://ehryk.github.io/espkey" />
<meta property="og:title" content="ESPKey" />
<meta property="og:description" content="ESPKey - An ESPHome encryption key generator" />
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link rel="stylesheet" media="all" href="css/main.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.3/modernizr.min.js"></script>
<style>
.espkey-card {
background: rgba(0, 0, 0, 0.35);
border-radius: 1rem;
padding: 2rem;
border: 1px solid #444;
max-width: 700px;
margin: 0 auto 1.5rem;
}
.espkey-card h3 {
margin-top: 0;
margin-bottom: 0.5rem;
}
.espkey-sub {
color: #ccc;
margin-bottom: 1.5rem;
border-left: 3px solid #99CCFF;
padding-left: 1rem;
text-align: left;
}
.key-container {
background: rgba(0, 0, 0, 0.45);
border-radius: 0.75rem;
padding: 1.25rem;
word-break: break-all;
font-family: 'SF Mono', 'Fira Code', monospace;
font-size: 1rem;
margin: 1.5rem 0;
border: 1px solid #555;
}
.key-label {
font-weight: 600;
margin-bottom: 0.5rem;
font-size: 0.85rem;
text-transform: uppercase;
letter-spacing: 0.5px;
color: #ccc;
text-align: left;
}
.espkey-card button {
background: #920E15;
color: white;
border: none;
padding: 0.6rem 1.2rem;
border-radius: 2rem;
font-size: 0.9rem;
font-weight: 500;
cursor: pointer;
transition: background 0.2s;
margin-right: 0.75rem;
}
.espkey-card button:hover {
background: #b8121a;
}
.espkey-card button.secondary {
background: #555;
}
.espkey-card button.secondary:hover {
background: #777;
}
.copy-feedback {
display: inline-block;
margin-left: 0.5rem;
font-size: 0.8rem;
color: #99CCFF;
opacity: 0;
transition: opacity 0.2s;
}
.espkey-card hr {
margin: 1.5rem 0;
border: none;
border-top: 1px solid #555;
}
.yaml-hint {
background: #111;
color: #e2e8f0;
padding: 1rem;
border-radius: 0.75rem;
font-family: monospace;
font-size: 0.9rem;
overflow-x: auto;
text-align: left;
}
.espkey-note {
font-size: 0.85rem;
margin-top: 0.75rem;
color: #aaa;
text-align: left;
}
.espkey-footer-note {
font-size: 0.85rem;
color: #aaa;
text-align: center;
margin-bottom: 1rem;
}
</style>
</head>
<body>
<!--[if lt IE 7]>
<p class="chromeframe">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.</p>
<![endif]-->
<div class="page">
<h1>ESPKey</h1>
<h5>An ESPHome encryption key generator — for more: <a href="/">home</a>, <a href="https://github.com/Ehryk">github</a>, <a href="http://www.ericmenze.com/cv/portfolios/">portfolio</a> or <a href="mailto:ehryk42@gmail.com">email</a>.</h5>
<div class="espkey-card">
<h3>ESPHome API Encryption Key</h3>
<div class="espkey-sub">Random 32-byte base64 key — regenerated each time you open or refresh this page.</div>
<div class="key-label">Your generated key</div>
<div class="key-container" id="keyDisplay">-- generating --</div>
<div>
<button id="copyBtn">Copy key</button>
<button id="refreshBtn" class="secondary">Regenerate</button>
<span id="copyFeedback" class="copy-feedback">Copied!</span>
</div>
<hr>
<div class="key-label">Example usage in ESPHome YAML</div>
<div class="yaml-hint" id="yamlSnippet">
# Paste your key below
</div>
<p class="espkey-note">
The key above is generated locally in your browser — never sent to any server.
</p>
</div>
<p class="espkey-footer-note">Reload the page or click Regenerate to create a new secure key.</p>
<footer>
<hr />
<p>© Eric Menze 2026</p>
</footer>
</div>
<script>
(function () {
function generateBase64Key() {
var bytes = new Uint8Array(32);
crypto.getRandomValues(bytes);
var binary = '';
for (var i = 0; i < bytes.length; i++) {
binary += String.fromCharCode(bytes[i]);
}
return btoa(binary);
}
function updateUI() {
var key = generateBase64Key();
document.getElementById('keyDisplay').innerText = key;
document.getElementById('yamlSnippet').innerText =
'api:\n encryption:\n key: "' + key + '"';
return key;
}
updateUI();
var copyBtn = document.getElementById('copyBtn');
var refreshBtn = document.getElementById('refreshBtn');
var copyFeedback = document.getElementById('copyFeedback');
copyBtn.addEventListener('click', async function () {
var keyText = document.getElementById('keyDisplay').innerText;
try {
await navigator.clipboard.writeText(keyText);
copyFeedback.style.opacity = '1';
setTimeout(function () {
copyFeedback.style.opacity = '0';
}, 1500);
} catch (err) {
alert('Could not copy: ' + err);
}
});
refreshBtn.addEventListener('click', function () {
updateUI();
copyFeedback.style.opacity = '0';
});
})();
</script>
</body>
</html>