fairDataSociety / fds.js

Ethereum Web3 Stack SDK Prototype
GNU Lesser General Public License v3.0
19 stars 13 forks source link

OPEN stream file through encryption to handle large files #10

Open significance opened 5 years ago

significance commented 5 years ago

https://www.npmjs.com/package/filereader-stream

significance commented 5 years ago
const crypto = require('crypto');
const fs = require('fs');

const algorithm = 'aes-192-cbc';
const password = 'Password used to generate key';
// Use the async `crypto.scrypt()` instead.
const key = crypto.scryptSync(password, 'salt', 24);
// Use `crypto.randomBytes()` to generate a random iv instead of the static iv
// shown here.
const iv = Buffer.alloc(16, 0); // Initialization vector.

const cipher = crypto.createCipheriv(algorithm, key, iv);

const input = fs.createReadStream('test.js');
const output = fs.createWriteStream('test.enc');

input.pipe(cipher).pipe(output);

https://nodejs.org/api/crypto.html

significance commented 5 years ago

interesting strategy - perhaps could upload to many swarm endpoints? http://www.resumablejs.com/