benlaurie / objecthash

A way to cryptographically hash objects (in the JSON-ish sense) that works cross-language. And, therefore, cross-encoding.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Binary data

tarcieri opened this issue · comments

Presently objecthash mandates all strings be valid Unicode. This makes it difficult to authenticate arbitrary binary data.

It'd be nice if there were an actual binary type. I think binary data should probably be added in addition to (not as a replacement for) the Unicode string type, so automatic normalization is still an option.

Tough to pick a domain qualifier for this though, given b is already boolean and s is already set. I ended up informally using o in one of my projects.

In TJSON I ended up using case to distinguish scalar and non-scalar types (i.e. capital for non-scalars, lower case for scalars). This allowed me to have S for set and s for string.

#40 makes objecthash "work" for []byte types. Although it will treat them as lists of (unsigned) integers. This might be problematic given that binary data should most probably be hashed as a single binary blob.

I'm having horrible horrible flashbacks to Erlang right now

We should definitely fix that, @maljub01.

Oh, you already did. :-)