▲ | cogman10 7 days ago | |||||||||||||||||||||||||||||||||||||||||||
I don't really love this. It just feels so wasteful. JWT does it as well. Even in this example, they are double base64 encoding strings (the salt). It's really too bad that there's really nothing quite like json. Everything speaks it and can write it. It'd be nice if something like protobuf was easier to write and read in a schemeless fashion. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | dlt713705 7 days ago | parent | next [-] | |||||||||||||||||||||||||||||||||||||||||||
What’s wrong with this? The purpose of Base64 is to encode data—especially binary data—into a limited set of ASCII characters to allow transmission over text-based protocols. It is not a cryptographic library nor an obfuscation tool. Avoid encoding sensitive data using Base64 or include sensitive data in your JWT payload unless it is encrypted first. | ||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||
▲ | zokier 7 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
> It's really too bad that there's really nothing quite like json messagepack/cbor are very similar to json (schemaless, similar primitive types) but can support binary data. bson is another similar alternative. All three have implementations available in many languages, and have been used in big mature projects. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | reactordev 7 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
We just need to sacrifice n*field_count to a header describing the structure. We also need to define allowed types. | ||||||||||||||||||||||||||||||||||||||||||||
▲ | Muromec 7 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||||||||||||||
>Everything speaks it and can write it. asn.1 is super nice -- everything speaks it and tooling is just great (runs away and hides) | ||||||||||||||||||||||||||||||||||||||||||||
▲ | derefr 7 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||||||||||||||
> It'd be nice if something like protobuf was easier to write and read in a schemeless fashion. If you just want a generic, binary, hierarchical type-length-value encoding, have you considered https://en.wikipedia.org/wiki/Interchange_File_Format ? It's not that there are widely-supported IFF libraries, per se; but rather that the format is so simple that as long as your language has a byte-array type, you can code a bug-free IFF encoder/decoder in said language about five minutes. (And this is why there are no generic IFF metaformat libraries, ala JSON or XML libraries; it's "too simple to bother everyone depending on my library with a transitive dependency", so everyone just implements IFF encoding/decoding as part of the parser + generator for their IFF-based concrete file format.) What's IFF used in? AIFF; RIFF (and therefore WAV, AVI, ANI, and — perhaps surprisingly — WebP); JPEG2000; PNG [with tweaks]... • There's also a descendant metaformat, the ISO Base Media File Format ("BMFF"), which in turn means that MP4, MOV, and HEIF/HEIC can all be parsed by a generic IFF parser (though you'll miss breaking some per-leaf-chunk metadata fields out from the chunk body if you don't use a BMFF-specific parser.) • And, as an alternative, there's https://en.wikipedia.org/wiki/Extensible_Binary_Meta_Languag... ("EBML"), which is basically IFF but with varint-encoding of the "type" and "length" parts of TLV (see https://matroska-org.github.io/libebml/specs.html). This is mostly currently used as the metaformat of the Matroska (MKV) format. It's also just complex enough to have a standalone generic codec library (https://github.com/Matroska-Org/libebml). My personal recommendation, if you have some structured binary data to dump to disk, is to just hand-generate IFF chunks inline in your dump/export/send logic, the same way one would e.g. hand-emit CSV inline in a printf call. Just say "this is an IFF-based format" or put an .iff extension on it or send it as application/x-iff, and an ecosystem should be able to run with that. (And just like with JSON, if you give the IFF chunks descriptive names, people will probably be able to suss out what the chunks "mean" from context, without any kind of schema docs being necessary.) | ||||||||||||||||||||||||||||||||||||||||||||
|