Skip to content

Commit

Permalink
Add password confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
ggorlen committed Jan 24, 2023
1 parent c80876e commit cfcd01c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions creator/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,19 @@

setMessage("⏳ Importing key...")

// Whatever array of bytes is in the password field
let password = new TextEncoder().encode(document.getElementById("password").value)
const passwordEl = document.getElementById("password")
const passwordConfirmEl = document.getElementById("password-confirm")

// Whatever arrays of bytes are in the password fields
const password = new TextEncoder().encode(passwordEl.value)
const passwordConfirm = new TextEncoder().encode(passwordConfirmEl.value)

if (password.length == 0) {
throw new Error(`Empty password`)
}
else if (passwordEl.value !== passwordConfirmEl.value) {
throw new Error(`Passwords must match`)
}

// Import password into a Key suitable for use with Cryptography APIs
let passwordKey = await window.crypto.subtle.importKey(
Expand Down Expand Up @@ -324,6 +331,12 @@ <h1><a href="https://mprimi.github.io/portable-secret/">Portable Secret</a>: Sec
<input type="password" id="password" value="banana" required>
</label>
</div>
<div>
<label>
Confirm Password:<br>
<input type="password" id="password-confirm" value="banana" required>
</label>
</div>

<div>
Password hint:<br>
Expand Down

0 comments on commit cfcd01c

Please sign in to comment.