New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

base64 serialization / deserialization not working properly #535

Closed
paralin opened this Issue Dec 9, 2016 · 5 comments

Comments

Projects
None yet
2 participants
@paralin

paralin commented Dec 9, 2016

var protobufjs = require('protobufjs');
var ro = protobufjs.loadSync('./test.proto');

var test = ro.lookup('test.Binary');
var enc = test.encode({bytesField: 'abc='}).finish();
var dec = test.decode(enc);

var decb64 = dec.bytesField.toString('base64');
if (decb64 === 'abc=') {
  console.log('Test passed.');
} else {
  console.log(decb64 + ' != abc= (expected)');
}
syntax = "proto3";
package test;

message Binary {
  bytes bytes_field = 1;
}

Output:

AAAAAA== != abc= (expected)

Extracted from a failing test case in grpc. long is not installed. Node v6.9.1

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Dec 9, 2016

There is no base64 encoder/decoder included anymore. Have been thinking about making a minimal one for these cases.

@paralin

This comment has been minimized.

paralin commented Dec 9, 2016

Buffer can do it in Node and atob in the browser?

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Dec 9, 2016

Yeah, not much of an issue with node of course, but atob makes binary strings.

@dcodeIO dcodeIO assigned dcodeIO and unassigned dcodeIO Dec 9, 2016

dcodeIO added a commit that referenced this issue Dec 10, 2016

dcodeIO added a commit that referenced this issue Dec 10, 2016

@dcodeIO

This comment has been minimized.

Owner

dcodeIO commented Dec 10, 2016

Done, give it a try!

@paralin

This comment has been minimized.

paralin commented Dec 10, 2016

Looks good!

@paralin paralin closed this Dec 10, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment