-
Notifications
You must be signed in to change notification settings - Fork 0
/
key-template.html
143 lines (135 loc) · 4.51 KB
/
key-template.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Ecedehey private key:</title>
</head>
<body>
<div id="info"></div>
<div class="key pad">
<div class="key__public-key">
<h1>Ecedehey private key<span id="app-version"></span></h1>
<div class="key-box push-bottom">
<div class="key-box__title">Key Fingerprint</div>
<div class="key-box__key" id="public-key-fingerprint"></div>
</div>
<p>
Ecedehey is completely browser-based and client side, no data is sent
to the server. It solely relies on the
<a
href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API"
target="_blank"
>WebCrypto API</a
>. Read more about it in the
<a
href="https://www.palmenhq.dev/annotated/2023/06/fun-with-webcrypto/"
>blog post</a
>.
</p>
<p></p>
<div class="error push-bottom">
<strong>Warning!</strong> Please note that this is built for
educational purposes and has not been reviewed by any security expert.
Do <strong>not</strong> rely on it for sensitive files.
</div>
</div>
<div>
<hr />
<h2>Encrypt for target</h2>
<p>
Use this private key HTML file together with a public key JWK to
encrypt a file, which can only be decrypted with the target private
key HTML file.
</p>
<div>
<label class="key-box push-bottom">
<span>Target public key (jwk)</span>
<input
type="file"
id="other-public-key-input"
accept=".jwk"
class="file-input"
/>
</label>
<div
class="key-box display-none push-bottom"
id="other-public-key-fingerprint"
>
<div class="key-box__title">Target key fingerprint</div>
<pre class="key-box__key"></pre>
</div>
</div>
<div>
<label class="key-box push-bottom">
<span>File to encrypt</span>
<input type="file" id="file-to-encrypt" class="file-input"
/></label>
</div>
<div>
<button id="encrypt-button" class="button push-bottom" disabled>
Encrypt & download
</button>
</div>
</div>
<hr />
<div class="key__encryption">
<h1>Target public key</h1>
<p>
Download this public key and import it in an Ecedehey private key HTML
file to encrypt something that can be decrypted with this private key
file.
</p>
<div class="key-box push-bottom">
<div class="key-box__title">Public key</div>
<pre id="public-key" class="key-box__key"></pre>
</div>
<a
href="#"
id="public-key-download"
class="button full-width push-bottom"
>Download target public key</a
>
</div>
<div>
<hr />
<h2>Decrypt</h2>
<p>Decrypt a file that was encrypted with this target public key.</p>
<div>
<label class="key-box push-bottom">
<span>File to decrypt</span>
<input
type="file"
id="decrypt-file-input"
accept=".ecdhmsg"
class="file-input"
/>
</label>
</div>
<div>
<button id="decrypt-button">Decrypt & download</button>
</div>
</div>
</div>
</body>
<script>
window.__ECEDEHEY_VERSION__ = '%VERSION%'
</script>
<script type="module">
import { convertToCryptoKey, jsonParseBase64Url } from './src/keys'
import { initializeKey } from './src/main-key'
let privateKeyPlainText
if (process.env.NODE_ENV === 'development') {
privateKeyPlainText =
'eyJjcnYiOiJQLTI1NiIsImQiOiI1WU52UmQ1bWpkVnNUdGlzbVJybW05TFJ5RWN5RGlQeVZXTlo2NE5HV1FnIiwiZXh0Ijp0cnVlLCJrZXlfb3BzIjpbImRlcml2ZUtleSJdLCJrdHkiOiJFQyIsIngiOiI1SnRFVE54WGRvblp5dEdfN0tueFAtV2dhQl9iY1k4LWROYWF0N09WYld3IiwieSI6InRxYldWaGo5MWJaeXUzbTloMFhZblRHYktjem1iQ3Fqa3RnRGtaUWFxeUkifQ=='
} else {
privateKeyPlainText = '%PRIVATE_KEY%'
}
;(async () => {
const privateKey = await convertToCryptoKey(
jsonParseBase64Url(privateKeyPlainText)
)
initializeKey(privateKey)
})()
</script>
</html>