-
Notifications
You must be signed in to change notification settings - Fork 0
/
decrypt.html
121 lines (110 loc) · 3.52 KB
/
decrypt.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
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Decrypt by @mryhryki/simple-encryption</title>
<style>
* {
box-sizing: border-box;
}
h1 {
text-align: center;
}
main {
margin: 0 auto;
max-width: 960px;
padding: 1rem;
}
label {
align-items: center;
display: flex;
flex-direction: row;
width: 100vw;
}
select, input[type="text"], textarea {
padding: 0.5rem;
display: block;
flex-grow: 1;
width: 100%;
}
input[type="submit"] {
text-align: center;
padding: 0.5rem 1rem;
font-size: 1.2rem;
}
</style>
</head>
<body>
<main>
<h1>Decrypt by <a href="https://github.com/mryhryki/simple-encryption" target="_blank" rel="noreferrer noopener">@mryhryki/simple-encryption</a></h1>
<form id="decryption-form">
<p>
<label>
<div>Crypt Algorithem</div>
<select id="crypt-algorithem">
<option value="AES-GCM">AES-GCM</option>
<option value="AES-CBC">AES-CBC</option>
</select>
</label>
</p>
<p>
<label>
<div>Secret Key (Required)</div>
<input id="secret-key" type="text"/>
</label>
</p>
<p>
<label>
<div>Initial Vector (Required)</div>
<input id="initial-vector" type="text"/>
</label>
</p>
<p>
<label>
<div>Encrypted Hex Text</div>
<textarea id="encrypted-hex-text" rows="10"></textarea>
</label>
</p>
<p style="text-align: center;">
<input type="submit" value="🔓 DECRYPT"/>
</p>
</form>
<p>
<label>
<div>Plain Text</div>
<textarea id="plain-text" rows="10" disabled></textarea>
</label>
</p>
</main>
<script id="elements">
const cryptAlgorithemSelect = document.getElementById("crypt-algorithem")
const secretKeyInput = document.getElementById("secret-key")
const initialVectorInput = document.getElementById("initial-vector")
const encryptedHexTextInput = document.getElementById("encrypted-hex-text")
const plainTextInput = document.getElementById("plain-text")
const decryptionForm = document.getElementById("decryption-form")
decryptionForm.addEventListener('submit', (event) => {
event.preventDefault();
const alg = cryptAlgorithemSelect.value
const key = secretKeyInput.value.trim()
const iv = initialVectorInput.value.trim()
const data = encryptedHexTextInput.value.trim()
if (alg === '') return alert('Crypt Algorithem is required')
if (key === '') return alert('Secret Key is required')
if (iv === '') return alert('Initial Vector is required')
if (data === '') return alert('Plain Text is required');
decrypt({alg, key, iv, data})
.then(({plainData}) => {
plainTextInput.value = new TextDecoder().decode(plainData)
})
.catch(alert)
})
</script>
<script id="common">
const decrypt = async ({alg, key, iv, data}) => {
const {decrypt} = await import("https://cdn.skypack.dev/@mryhryki/simple-encryption")
return await decrypt({alg, key, iv, data: data})
}
</script>
</body>
</html>