Commit 6204d79 1 parent 7decb39 commit 6204d79 Copy full SHA for 6204d79
File tree 4 files changed +25
-22
lines changed
4 files changed +25
-22
lines changed Original file line number Diff line number Diff line change 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
+ } )
2
11
3
12
function submitPassword ( ) {
4
- let password = document . getElementById ( " submittedPassword" ) . value ;
13
+ let password = document . getElementById ( ' submittedPassword' ) . value ;
5
14
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
+ }
Original file line number Diff line number Diff line change
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 } ;
Original file line number Diff line number Diff line change 17
17
< h2 > Test de la fuite de mot de passe</ h2 >
18
18
< p > Cette page permet de tester si votre mot de passe est présent dans la base < a
19
19
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 ">
22
22
< p > Le mot de passe n'est pas envoyé au serveur, uniquement les premiers caractères de son hash.</ p >
23
23
</ div >
24
24
25
- < script >
26
- document . addEventListener ( "keyup" , ( { key} ) => {
27
- if ( key === "Enter" ) {
28
- submitPassword ( )
29
- }
30
- } )
31
- </ script >
32
25
</ body >
33
26
</ html >
Original file line number Diff line number Diff line change 1
- import { hashPrefix } from "../static/check_password_leak .js" ;
1
+ import { hashPrefix } from "../static/hash .js" ;
2
2
3
3
test ( 'hash prefix is identical to Python version' , async ( ) => {
4
4
let prefix = await hashPrefix ( "rockyou" ) ;
You can’t perform that action at this time.
0 commit comments