Skip to content
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
Closed

base64 serialization / deserialization not working properly #535

paralin opened this issue Dec 9, 2016 · 5 comments

Comments

@paralin
Copy link

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
Copy link
Member

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
Copy link
Author

paralin commented Dec 9, 2016

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

@dcodeIO
Copy link
Member

dcodeIO commented Dec 9, 2016

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

@dcodeIO
Copy link
Member

dcodeIO commented Dec 10, 2016

Done, give it a try!

@paralin
Copy link
Author

paralin commented Dec 10, 2016

Looks good!

@paralin paralin closed this as completed Dec 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants