This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
let d = "";
|
||||
let n = "";
|
||||
|
||||
async function encrypt() {
|
||||
const plaintext = document.getElementById("plaintext").value;
|
||||
const size = document.getElementById("keysize").value;
|
||||
@@ -11,7 +14,10 @@ async function encrypt() {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ text: plaintext, keysize: parseInt(size) })
|
||||
});
|
||||
document.getElementById("ciphertext").value = await res.text();
|
||||
const answer = await res.json();
|
||||
document.getElementById("ciphertext").value = answer.ciphertext;
|
||||
d = answer.d;
|
||||
n = answer.n;
|
||||
} catch (e) { alert("Impossibile connettersi al server Javalin."); }
|
||||
}
|
||||
|
||||
@@ -24,7 +30,7 @@ async function decrypt() {
|
||||
try {
|
||||
const res = await fetch("/seal/rsa/decrypt", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ text: input })
|
||||
body: JSON.stringify({ text: input, n: n, d: d })
|
||||
});
|
||||
document.getElementById("decodedtext").value = await res.text();
|
||||
} catch (e) { alert("Impossibile connettersi al server."); }
|
||||
|
||||
Reference in New Issue
Block a user