Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use password type for inputs #26

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 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 @@ -319,10 +326,17 @@ <h1><a href="https://mprimi.github.io/portable-secret/">Portable Secret</a>: Sec
</div>

<div>
Password:<br>
<input type="text" id="password" value="banana" required>
<label>
Password:<br>
<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
2 changes: 1 addition & 1 deletion creator/secret-template.html
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ <h4>Password hint:</h4>

<div>
<h4>Password:</h4>
<input type="text" id="password" placeholder="See hint above" class="password_input" required>
<input type="password" id="password" placeholder="See hint above" class="password_input" required>
</div>

<div>
Expand Down