Node.js encrypts large file using AES

后端 未结 3 1639
花落未央
花落未央 2020-12-08 12:34

I try to use following code to encrypt a file of 1 GB. But Node.js abort with \"FATAL ERROR: JS Allocation failed - process out of memory\". How can I deal with it?

3条回答
  •  情书的邮戳
    2020-12-08 12:58

    I would simply use the Fileger to do it. It's a promise-based package and a clean alternative to the NodeJS filesystem.

    const fileger = require("fileger")
    const file = new fileger.File("./your-file-path.txt");
    
    file.encrypt("your-password") // this will encrypt the file
       .then(() => {
          file.decrypt("your-password") // this will decrypt the file
       })
    

提交回复
热议问题