Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed SJCL to make the same encrypted AES 256 output when the PassPhrase is the same
    primarykey
    data
    text
    <p>I'm working on uploading file encrypted on the client side using Node.js, and I use SJCL (Stanford Javascript Crypto Library) to encrypt the file with Javascript.</p> <p>But i noticed that the output or the result of the encryption is always different even with the same PassPhrase.</p> <p>After few research i found that it's because the salt is random each time and i need to do a 'nosalt' (sorry I'm new to everything here cryptographie, Node.js)</p> <p>How can I change my code (or SJCL code) to generate the exact encrypt output each time when the password is the same.</p> <p>My app is based on "Cryptloader" project, you can find it here: <a href="https://github.com/Kryil/Cryptloader" rel="nofollow">https://github.com/Kryil/Cryptloader</a></p> <p>Encrypt:</p> <pre><code>var part = file_queue[data["id"]].slice(start, end) var reader = new FileReader() reader.onload = function(e) { var passwd = document.getElementById("password").value console.log("Uploading arraybuffer of size " + e.target.result.byteLength) var i32a = new Int32Array(e.target.result) var out = i32a.toJSONArray() console.log("crypting: " + out) var crypted = sjcl.encrypt(passwd, out) ws.send(JSON.stringify({ "type": "fileslice", "data": {"id": data["id"], "slice": slice, "data": crypted} })) } reader.readAsArrayBuffer(part) </code></pre> <p>Decrypt:</p> <pre><code>var decrypted = sjcl.decrypt(passwd, data["data"]) file_contents[file]["data"].push(new Int32Array(JSON.parse(decrypted))) </code></pre> <p>This is irrelevant question, but not all files upload correctly, some of them produce an error, but when i Change Int32Array to either Int16Array or Int8Array, it works for them but produce error for other files, what causes that and how to fix it. The error:</p> <pre><code>Uncaught RangeError: ArrayBuffer length minus the byteOffset is not a multiple of the element size. (Chrome Latest version, Win 7) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload