forked from Ailur/burgernotes-server
Hopefully migrate to SHA-3
This commit is contained in:
parent
54ec23cc62
commit
aa35c8f7b4
|
@ -88,7 +88,7 @@ signupButton.addEventListener("click", (event) => {
|
||||||
showElements(true)
|
showElements(true)
|
||||||
statusBox.innerText = "Signing in..."
|
statusBox.innerText = "Signing in..."
|
||||||
|
|
||||||
async function hashpass(pass) {
|
async function hashpassold(pass) {
|
||||||
const key = await hashwasm.argon2id({
|
const key = await hashwasm.argon2id({
|
||||||
password: pass,
|
password: pass,
|
||||||
salt: await hashwasm.sha512(pass),
|
salt: await hashwasm.sha512(pass),
|
||||||
|
@ -101,6 +101,11 @@ signupButton.addEventListener("click", (event) => {
|
||||||
return key
|
return key
|
||||||
};
|
};
|
||||||
|
|
||||||
|
async function hashpass(pass) {
|
||||||
|
const key = await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(pass))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
|
||||||
|
return key
|
||||||
|
};
|
||||||
|
|
||||||
fetch("/api/login", {
|
fetch("/api/login", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
|
@ -122,9 +127,40 @@ signupButton.addEventListener("click", (event) => {
|
||||||
window.location.href = "/app"
|
window.location.href = "/app"
|
||||||
}
|
}
|
||||||
else if (response.status == 401) {
|
else if (response.status == 401) {
|
||||||
statusBox.innerText = "Wrong username or password..."
|
fetch("/api/login", {
|
||||||
showInput(1)
|
method: "POST",
|
||||||
showElements(true)
|
body: JSON.stringify({
|
||||||
|
username: username,
|
||||||
|
password: await hashpassold(password)
|
||||||
|
}),
|
||||||
|
headers: {
|
||||||
|
"Content-type": "application/json; charset=UTF-8"
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((response) => response)
|
||||||
|
.then((response) => {
|
||||||
|
async function doStuff() {
|
||||||
|
let responseData = await response.json()
|
||||||
|
if (response.status == 200) {
|
||||||
|
localStorage.setItem("DONOTSHARE-secretkey", responseData["key"])
|
||||||
|
localStorage.setItem("DONOTSHARE-password", await hashwasm.sha512(password))
|
||||||
|
|
||||||
|
window.location.href = "/app"
|
||||||
|
}
|
||||||
|
else if (response.status == 401) {
|
||||||
|
|
||||||
|
statusBox.innerText = "Wrong username or password..."
|
||||||
|
showInput(1)
|
||||||
|
showElements(true)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
statusBox.innerText = "Something went wrong! (error code: " + response.status + ")"
|
||||||
|
showInput(1)
|
||||||
|
showElements(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
doStuff()
|
||||||
|
});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
statusBox.innerText = "Something went wrong! (error code: " + response.status + ")"
|
statusBox.innerText = "Something went wrong! (error code: " + response.status + ")"
|
||||||
|
|
|
@ -53,15 +53,8 @@ signupButton.addEventListener("click", (event) => {
|
||||||
statusBox.innerText = "Creating account, please hold on..."
|
statusBox.innerText = "Creating account, please hold on..."
|
||||||
|
|
||||||
async function hashpass(pass) {
|
async function hashpass(pass) {
|
||||||
const key = await hashwasm.argon2id({
|
/* Very hacky solution to sha3 with 128 iterations */
|
||||||
password: pass,
|
const key = await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(await hashwasm.sha3(pass)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))));
|
||||||
salt: await hashwasm.sha512(pass),
|
|
||||||
parallelism: 1,
|
|
||||||
iterations: 256,
|
|
||||||
memorySize: 512,
|
|
||||||
hashLength: 32,
|
|
||||||
outputType: "encoded"
|
|
||||||
});
|
|
||||||
return key
|
return key
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue