Skip to content

Commit 6204d79

Browse files
committed
GH-2 # fix submitPassword not referenced
1 parent 7decb39 commit 6204d79

File tree

4 files changed

+25
-22
lines changed

4 files changed

+25
-22
lines changed

src/static/check_password_leak.js

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import xxhash from "xxhash-wasm";
1+
import { hashPrefix } from './hash.js';
2+
3+
document.addEventListener("keyup", ({key}) => {
4+
if (key === 'Enter') {
5+
submitPassword()
6+
}
7+
})
8+
document.getElementById('submittedPasswordButton').addEventListener('click', (e) => {
9+
submitPassword();
10+
})
211

312
function submitPassword() {
4-
let password = document.getElementById("submittedPassword").value;
13+
let password = document.getElementById('submittedPassword').value;
514
hashPrefix(password).then(prefix => alert(prefix));
6-
}
7-
8-
async function hashPrefix(password) {
9-
const { h32, h64 } = await xxhash();
10-
let digest = h32(password);
11-
let hexadecimal_digest = digest.toString(16)
12-
return hexadecimal_digest.substring(0, 5)
13-
}
14-
15-
export {hashPrefix};
15+
}

src/static/hash.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import xxhash from "xxhash-wasm";
2+
3+
async function hashPrefix(password) {
4+
const { h32, h64 } = await xxhash();
5+
let digest = h32(password);
6+
let hexadecimal_digest = digest.toString(16)
7+
return hexadecimal_digest.substring(0, 5)
8+
}
9+
10+
export {hashPrefix};

src/static/index.html

+2-9
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,10 @@
1717
<h2>Test de la fuite de mot de passe</h2>
1818
<p>Cette page permet de tester si votre mot de passe est présent dans la base <a
1919
href="https://en.wikipedia.org/wiki/RockYou#Data_breach" target="_blank">RockYou</a>.</p>
20-
<input id=submittedPassword/>
21-
<input type="button" onclick="submitPassword()" value="Tester">
20+
<input id="submittedPassword"/>
21+
<input id="submittedPasswordButton" type="button" value="Tester">
2222
<p>Le mot de passe n'est pas envoyé au serveur, uniquement les premiers caractères de son hash.</p>
2323
</div>
2424

25-
<script>
26-
document.addEventListener("keyup", ({key}) => {
27-
if (key === "Enter") {
28-
submitPassword()
29-
}
30-
})
31-
</script>
3225
</body>
3326
</html>

src/static_test/hashPrefix.test.js src/static_test/hash.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { hashPrefix } from "../static/check_password_leak.js";
1+
import { hashPrefix } from "../static/hash.js";
22

33
test('hash prefix is identical to Python version', async () => {
44
let prefix = await hashPrefix("rockyou");

0 commit comments

Comments
 (0)