encryption.js: use JSON under base64
This commit is contained in:
parent
338c8ef371
commit
a5b4c628c6
@ -87,21 +87,24 @@ async function enc () {
|
|||||||
msgEncoded
|
msgEncoded
|
||||||
);
|
);
|
||||||
|
|
||||||
let output = concatBuf(concatBuf(ciphertext, salt), iv);
|
let output = {
|
||||||
|
"ciphertext": bufTo64(ciphertext),
|
||||||
|
"salt": bufTo64(salt),
|
||||||
|
"iv": bufTo64(iv)
|
||||||
|
}
|
||||||
|
|
||||||
outBox.innerHTML = `${bufTo64(output)}`;
|
outBox.innerHTML = `${btoa(JSON.stringify(output))}`;
|
||||||
let keyExp = await exportKey (key);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function dec () {
|
async function dec () {
|
||||||
outBox = document.getElementById("plaintext");
|
outBox = document.getElementById("plaintext");
|
||||||
outBox.innerHTML = '';
|
outBox.innerHTML = '';
|
||||||
|
|
||||||
let msgEncoded = b64ToBuf(getMsg());
|
let msgEncoded = JSON.parse(atob(getMsg()));
|
||||||
|
|
||||||
let ciphertext = new Uint8Array(msgEncoded.slice(0, -32));
|
let ciphertext = new b64ToBuf(msgEncoded.ciphertext);
|
||||||
let iv = new Uint8Array(msgEncoded.slice(-16));
|
let iv = new Uint8Array(b64ToBuf(msgEncoded.iv));
|
||||||
let salt = new Uint8Array(msgEncoded.slice(-32, -16));
|
let salt = new Uint8Array(b64ToBuf(msgEncoded.salt));
|
||||||
|
|
||||||
let keyMaterial = await getKeyMaterial();
|
let keyMaterial = await getKeyMaterial();
|
||||||
let key = await getKey(keyMaterial, salt);
|
let key = await getKey(keyMaterial, salt);
|
||||||
|
Loading…
Reference in New Issue
Block a user