KuroLabs/stegcloak

RangeError: Input buffers must have the same byte length

Explosion-Scratch opened this issue · 1 comments

I am getting this error:

RangeError: Input buffers must have the same byte length
    at decrypt (/home/runner/encryptstuff/node_modules/stegcloak/components/encrypt.js:41:10)
    at StegCloak.reveal (/home/runner/encryptstuff/node_modules/stegcloak/stegcloak.js:94:7)
    at /home/runner/encryptstuff/index.js:24:22
    at Layer.handle [as handle_request] (/home/runner/encryptstuff/node_modules/express/lib/router/layer.js:95:5)
    at next (/home/runner/encryptstuff/node_modules/express/lib/router/route.js:137:13)
    at next (/home/runner/encryptstuff/node_modules/express/lib/router/route.js:131:14)
    at next (/home/runner/encryptstuff/node_modules/express/lib/router/route.js:131:14)
    at next (/home/runner/encryptstuff/node_modules/express/lib/router/route.js:131:14)
    at next (/home/runner/encryptstuff/node_modules/express/lib/router/route.js:131:14)
    at next (/home/runner/encryptstuff/node_modules/express/lib/router/route.js:131:14)

Using this code to decrypt:

// Use an express route, suitable for either GET or POST 
app.all("/decrypt", (req, res) => {
	// Conbining req.query and req.body
	var body = {...req.query, ...req.body}
	// Enc is a 'new Stegcloak(true, false)'
	let decrypted = enc.reveal(body.data || body.text, body.password || body.pass);
	// Log
	console.log(decrypted)
	// Send to client
	res.json(decrypted);
})

With this form body:

// POST /decrypt
{
  "text": "Here's ⁢‍⁢⁣⁢⁢‌‍⁢‌‌‌⁢‌⁡‍‌⁡‍⁢⁢‍⁡⁢⁡‌‍⁡‌⁡⁢‌‍⁢‌‌⁡‌‍⁢‌‌‍⁢⁤‍⁢⁣‍⁢‍⁢⁢‌‌⁢‍⁡⁢⁢⁢⁡‍⁢⁢⁤‍‌‍‌⁢⁢‌‍‌⁢‍⁢⁢⁡⁣‍⁢⁣‌‍⁡⁢⁣⁢‍⁡‌⁢⁣‌‍⁤‌⁢‌‍⁤‌⁢‌⁣⁡⁢⁡⁣⁢⁢⁡⁢⁡‌⁤‍⁢‌‌⁣⁢‌ ‍⁡‍⁢⁢⁢⁡‌‍⁡‌⁢⁢⁢‌⁡‌‌⁤‌⁢⁡‍⁤‌‌‍⁢⁢⁡‍⁢⁡‍‌⁤‌‌⁢⁡⁢‌⁢⁡⁢‍⁢⁢⁡‌‍‌‍⁢⁡‍⁢⁢⁢⁡⁢‌‍⁢⁡‍⁡‌‍⁢‌‌⁡‍‌‌⁢⁡‌‌‌⁤‍⁡‌‌‍⁡‍⁢⁡‍⁡⁢‌⁢‍⁤⁤⁢⁡⁢‍‌⁢⁣⁡⁢⁡⁢⁡⁢‍⁢⁡‌‍⁡‌⁡‌‌‌⁡⁣‌⁡‌‌‌⁡⁢ ‌‍⁡⁢‌⁢⁢‍⁤‍‌⁡‌⁢⁢‍⁢‌⁢⁢‌⁢‍‌‍⁡⁢‌‌⁤⁢⁤‍⁡‌⁢‌‍⁢⁢‍‌⁡‍⁡⁢‌‌⁣‍⁤⁢‍‌‌‌‌‌⁡⁢‌‍⁢‍‌⁤⁡‌‍⁡⁣⁣⁤⁢⁡‌‍⁤⁢⁣⁢‍⁤‌‍⁢‌⁢‍⁡⁢⁢⁢⁢⁡‌⁡⁢⁣⁢⁣‌⁡‌⁢‌‌⁢‍⁡‌⁤⁡‌‌‌⁢⁤⁡‍‌⁡‌⁡⁢⁣⁣⁡‌‍‌‍ ⁡⁢‌⁢‌⁢‌⁤⁢‌⁢‍⁡⁢⁢⁢‍⁢‌⁡‌‌⁤⁣‍‌⁢⁡‌‍⁡‌⁢‍⁢⁢⁣‌‍‌‌⁡‌⁤⁢‌⁢⁢⁣⁤‌⁡‍⁡‍⁡⁣⁢⁡‌⁢⁢‍‌‌⁢‌⁣⁡‌⁡‌⁤‌⁡⁢‌⁡⁢⁡‌⁢⁣⁢⁢‌⁡⁣⁤‌⁡‍⁡⁢⁡⁢‌⁢‍⁢‌‍⁢‌‌⁤⁢⁡⁢‌⁢⁣‍⁢‌⁣⁢⁡⁢⁡‌‌‌⁡‌⁡‌‌‍‌‍⁡ ⁢‌⁢⁢⁡‌⁡⁢⁡⁢‌‌‌⁢⁡‍‌⁡⁣‍‌‌⁡‌⁢⁢‍⁡⁢‌‌‌⁡‍⁢⁡⁣⁡⁢⁢‌⁢‌⁢‍⁡⁣‍⁢‍⁡⁣‌⁤‍‌‍⁡⁢‌⁢⁢⁡‌⁢⁡⁢⁢⁡‌⁡‌⁡‍⁤⁣‌‌⁢‍⁤⁢‌⁡⁣‍⁢⁡‌‍⁡⁢⁢⁣⁢⁡‍⁢⁢⁢‌‌⁢⁢‌‍‌‌⁢⁢‍⁢‍⁡‌⁡‌⁡‌⁢⁢⁢⁢‌⁡⁢⁢‌‌‌⁣⁢ ⁢⁢⁤‌⁡⁢⁡⁢⁡‍‌⁣‌⁢‌‌⁡‍‌⁢‌⁣⁡‍⁢‍⁡⁢‌⁡‍‌⁤‍⁢‍⁤‍‌⁡⁢‌‍‌⁡‍‌⁢⁡‌‍‌⁡‌⁡‌‍⁤⁢⁤‍‌‍⁡‍‌⁢⁢⁢‌⁤⁡⁣‌⁢⁡⁢⁡‌⁣‌‍⁢‍⁢⁢⁢‌⁢‌⁢‌⁤‌⁡‌⁢‌⁣⁢‌‌‍⁢‌⁡⁣⁡‍⁢⁢‌⁤‍⁢⁡‌⁢‌⁢⁤⁡‌‌⁤⁤‌⁡⁢⁢⁢⁢ ‌‌‌⁡⁢‌‌⁢⁢⁡⁣⁣⁢‌⁡⁢⁢‌⁣‌‍⁡‍‌⁢⁤‌⁢⁣‌‍‌‌‍⁤⁤‌⁡‌‌⁢‍‌‌‌‌‌⁢⁢⁣‍⁢‌‌⁢⁡‌‍⁤‍‌‌⁤‍⁢⁣⁢‍⁤⁢⁣⁢⁡⁢‌‍‌⁡⁢‌the code!",
  "pass": "42"
}

Encrypted this:

// POST /encrypt
{
  "hide": "chrome.contextMenus.create({    id: `encrypt`,     title: `Encrypt "%s"`,    contexts: [\'selection\'],    onclick: (info) => {       const { menuItemId: id , selectionText: selected } = info;       console.log(info);       encrypt(selected).then((res) => {          prompt(_gui.encrypt, res)       });    } }, log("Created context menu"))",
  "show": "Here's the code!",
  "pass": "42"
}

Express code to encrypt:

app.all("/encrypt", (req, res) => {
	var body = {...req.query, ...req.body}
	let encrypted = enc.hide(body.secret || body.hide, body.password || body.pass, body.cover || body.show || body.text)
	res.json(encrypted);
})

This happens if the exact stegcloake'd output is not fed into decrypt.

Thank you!