Spaces:
Paused
Paused
Update server.js
Browse files
server.js
CHANGED
|
@@ -109,7 +109,7 @@ const scryptAsync = promisify(scrypt);
|
|
| 109 |
async function deriveKey(password, salt) { return scryptAsync(password, salt, KEY_LEN); }
|
| 110 |
function encryptChunk(dataBuffer, key) { const iv = randomBytes(IV_LEN); const cipher = createCipheriv('aes-256-gcm', key, iv); const encrypted = Buffer.concat([cipher.update(dataBuffer), cipher.final()]); const tag = cipher.getAuthTag(); return Buffer.concat([iv, encrypted, tag]); }
|
| 111 |
function decryptChunk(encBuffer, key) { if (encBuffer.length < OVERHEAD) throw new Error('Buffer trop court'); const iv = encBuffer.subarray(0, IV_LEN); const tag = encBuffer.subarray(encBuffer.length - TAG_LEN); const data = encBuffer.subarray(IV_LEN, encBuffer.length - TAG_LEN); const decipher = createDecipheriv('aes-256-gcm', key, iv); decipher.setAuthTag(tag); return Buffer.concat([decipher.update(data), decipher.final()]); }
|
| 112 |
-
function esc(s) { return String(s).replace(/&/g,'&').replace(/</g,'
|
| 113 |
|
| 114 |
function bufferToPng(buffer) {
|
| 115 |
const byteLen = buffer.length;
|
|
|
|
| 109 |
async function deriveKey(password, salt) { return scryptAsync(password, salt, KEY_LEN); }
|
| 110 |
function encryptChunk(dataBuffer, key) { const iv = randomBytes(IV_LEN); const cipher = createCipheriv('aes-256-gcm', key, iv); const encrypted = Buffer.concat([cipher.update(dataBuffer), cipher.final()]); const tag = cipher.getAuthTag(); return Buffer.concat([iv, encrypted, tag]); }
|
| 111 |
function decryptChunk(encBuffer, key) { if (encBuffer.length < OVERHEAD) throw new Error('Buffer trop court'); const iv = encBuffer.subarray(0, IV_LEN); const tag = encBuffer.subarray(encBuffer.length - TAG_LEN); const data = encBuffer.subarray(IV_LEN, encBuffer.length - TAG_LEN); const decipher = createDecipheriv('aes-256-gcm', key, iv); decipher.setAuthTag(tag); return Buffer.concat([decipher.update(data), decipher.final()]); }
|
| 112 |
+
function esc(s) { return String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"').replace(/'/g,'''); }
|
| 113 |
|
| 114 |
function bufferToPng(buffer) {
|
| 115 |
const byteLen = buffer.length;
|