mazira / base64-stream Goto Github PK
View Code? Open in Web Editor NEWContains new Node v0.10 style stream classes for encoding / decoding Base64 data
Contains new Node v0.10 style stream classes for encoding / decoding Base64 data
Hello,
thanks for the great library. We'd like to create a memory-friendly base64 encoder on top of it while working with bigger files. Although, it seems like a zip file encoded to base64 in stream cannot be properly decoded from an in-memory buffer and is corrupted. Please check https://github.com/appium/appium-support/pull/163/files#diff-76980d83b95b157bd0dc770da7793208R136 for the actual implementation and https://github.com/appium/appium-support/pull/163/files#diff-61daa1216539229f5c27de85022654dbR113 is the test for it.
I'm trying to encrypt a file into aes-256-cbc
and then make a base64
to have readable chars.
This is my code:
var fs = require('fs')
var crypto = require('crypto')
var base64 = require('base64-stream')
var algorithm = 'aes-256-cbc'
var password = 'ciao'
var encrypt = crypto.createCipher(algorithm, password)
var r = fs.createReadStream('hello.txt')
r.pipe(encrypt)
.pipe(base64.encode())
.pipe(fs.createWriteStream('out.enc'))
That basically returns a file with a content like:
5XhSTuk5/6DilIzIVQqy6/TORf+zvTNrYShuPERTuCs9NYP8eIFq7OpNPSCTNw+2xb2q8a1msg8inHkvYwFRBFqSO+LSeArun2y01iAznaMD61FsqeF4m+0a9mzb8zoXmm25zeDz9Q/WGhhuRs/TuBWHauJdcOiqzbJdBSgwMbv7NWFhhosgPODvauejYkIHo5ZtHOswtFhm8rrKpO7AyQ==
The right output in my case, should behave like the unix base64
bin that actually puts some new line every 76 chars:
5XhSTuk5/6DilIzIVQqy6/TORf+zvTNrYShuPERTuCs9NYP8eIFq7OpNPSCTNw+2xb2q8a1msg8i
nHkvYwFRBFqSO+LSeArun2y01iAznaMD61FsqeF4m+0a9mzb8zoXmm25zeDz9Q/WGhhuRs/TuBWH
auJdcOiqzbJdBSgwMbv7NWFhhosgPODvauejYkIHo5ZtHOswtFhm8rrKpO7AyQ==
Just to be able to decrypt it with:
openssl aes-256-cbc -d -a -nosalt -in out.enc -out out.txt -k ciao
Any hints?
The docs aren't very clear. For example, what's the input data format? Is binary assumed (like ArrayBuffer)?
Thank you for the great package!
The problem: I've read the docs, downloaded the package via npm
and started using it just to get an error about Base64Encode
not being a constructor. Digging into the source and commit log for this package, I've found out that the interface has changed and the docs in the readme describe the unreleased interface. Looking up the version in the package.json
didn't even help because it is the same as on npm
(what I usually do first, before looking into commit logs).
Would you mind to release the new package version, possibly as a new major version? Or at least change the version in the package.json
to make clear that the version in master
branch is a different one from that on npm
.
req.get("http://maps.googleapis.com/maps/api/streetview?size=300x300&location="+request.body.Destination.coordinates[0]+","+request.body.Destination.coordinates[1])
.pipe(base64.encode()).pipe(response);
This code looks like causing this exception
An unhandled exception occurred. Error: Can't set headers after they are sent.
It works removing the middle pipe command and streaming direct response.
In version 0.1.3, a call like this worked:
const base64Stream = require('base64-stream');
const stream = base64Stream.decode();
Now with version 0.1.4 you need to write it like this:
const {Base64Decode} = require('base64-stream');
const stream = new Base64Decode();
The original way to create a stream does not work anymore which makes this a breaking change because other packages need to adapt their code in order to work with this version.
But NPM just treats this as a bugfix release and just goes for the new version instead of the one specified in the package.json.
In my case i am using pageres-cli
which depends on screenshot-stream
which is now broken.
So i would like to ask you to unpublish the version and re-release it as a version 1.X or so to make sure
NPM sees it as a new version with breaking changes and does not simply install it like it does now.
like data:${contentType};base64,
I tried from, the source, but don't find a way yet
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.