Skip to content

cryptoENgine.js/HexEncoder.stringify() throws RangeError: Invalid array length #213

@jimhark

Description

@jimhark

I'm trying to encrypt a large (140 MB) html page using this command (PowerShell 7):

node .\cli\index.js .\page.html --password test --short --remember false

I get this error:

Exception has occurred: RangeError: Invalid array length
  at Array.push (<anonymous>)
    at Object.stringify (c:\staticrypt\lib\cryptoEngine.js:45:22)
    at Object.encrypt (c:\staticrypt\lib\cryptoEngine.js:84:50)
    at async encodeWithHashedPassword (c:\staticrypt\lib\codec.js:42:27)
    at async encodeAndGenerateFile (c:\staticrypt\cli\index.js:209:26) 

This occurs while processing the 112,813,857th byte. Results of Google searches
suggests this may be caused by a bug in the JavaScript V8 engine.

I expect this to encrypt this file because my machine has plenty of memory (64 GB, more than half free) and 140 MB doesn't approach any documented internal limits of V8 JavaScript.

My setup:

StatiCrypt version: 3.5.4
Node version: 22.17.0
Windows 11

Fix (workaround, really) is available on my fork:
https://github.com/jimhark/staticrypt/tree/ImproveBigFileSupport

I will submit a PR shortly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions