-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.html
More file actions
110 lines (91 loc) · 3.07 KB
/
Copy pathindex.html
File metadata and controls
110 lines (91 loc) · 3.07 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Bitwarden JSON Decryptor</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="header">
<h1>Bitwarden JSON Decryptor</h1>
<p>Decrypt your password-protected Bitwarden JSON exports locally in your browser</p>
</div>
<form class="form">
<div class="form__input">
<label for="file-input">Encrypted JSON File</label>
<input type="file" accept=".json" id="file-input" required>
</div>
<div class="form__input">
<label for="password-input">Master Password</label>
<input
type="password"
id="password-input"
placeholder="Enter your master password"
required
>
<div class="form__checkbox">
<input type="checkbox" id="show-password">
<label for="show-password">Show password</label>
</div>
</div>
<button class="form__button">Decrypt</button>
<p>All decryption happens locally in your browser. Your password and data never leave your device.</p>
<p>
<a
href="https://github.com/astik-dev/bitwarden-json-decryptor"
target="_blank"
>GitHub</a>
</p>
</form>
<div class="success" style="display: none;">
<p>✅ Decryption successful!</p>
<a id="download-json-link" download="vault.json">Download Decrypted JSON</a>
<a id="view-json-link" target="_blank">View Decrypted JSON</a>
</div>
<div class="failure" style="display: none;">
<p>❌ Decryption failed!</p>
<p id="error-message"></p>
</div>
<script src="js/bitwarden-crypto.js"></script>
<script src="js/decrypt.js"></script>
<script>
const fileInput = document.getElementById("file-input");
const passwordInput = document.getElementById("password-input");
const showPasswordCheckbox = document.getElementById("show-password");
document.querySelector("form").addEventListener("submit", event => {
event.preventDefault();
const jsonFile = fileInput.files[0];
const masterPassword = passwordInput.value;
const fileReader = new FileReader();
fileReader.onload = async () => {
let isDecryptionSuccessful = false;
try {
const json = fileReader.result;
const decryptedJson =
await decryptBitwardenJson(json, masterPassword);
isDecryptionSuccessful = true;
const blob = new Blob([decryptedJson], {
type: "application/json",
});
const url = URL.createObjectURL(blob);
document.getElementById("download-json-link").href = url;
document.getElementById("view-json-link").href = url;
passwordInput.value = "";
} catch (error) {
document.getElementById("error-message").textContent = error;
} finally {
document.querySelector(".success").style.display =
isDecryptionSuccessful ? "" : "none";
document.querySelector(".failure").style.display =
isDecryptionSuccessful ? "none" : "";
}
};
fileReader.readAsText(jsonFile);
});
showPasswordCheckbox.addEventListener("change", () => {
passwordInput.type = showPasswordCheckbox.checked ? "text" : "password";
});
</script>
</body>
</html>