[erlang-questions] canonical encoding for term_to_binary/binary_to_term ?

Guilherme Andrade g@REDACTED
Tue Nov 7 23:51:27 CET 2017


The ETF format[1] is fairly straight forward so, performance considerations
excluded, is shouldn't be too hard to code a custom encoder which creates a
bijective mapping between terms and binaries.

A while back I worked a bit on an ETF decoder with customizable
restrictions on which types to accept to decode (and which to reject); I'm
sharing it[2] in case someone finds it enlightening. I found the trickier
cases to be pids, ports, references and anonymous functions.

[1]: http://erlang.org/doc/apps/erts/erl_ext_dist.html
[2]:
https://github.com/g-andrade/restricted_etf/blob/master/src/restricted_etf.erl

On 7 November 2017 at 20:07, Benoit Chesneau <bchesneau@REDACTED> wrote:

> Following the recent discussion on maps ordering, I’m curious if someone
> has already worked on an implementation of a canonical
> term_to_binary/binary_to_term to be able to sign them and make sure we get
> the same data across the wire.
>
> Is there  any lib that does that around? For now i’m just using a
> canonical version of JSON but it’s pretty inefficient …
>
> - benoit
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



-- 
Guilherme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20171107/fd7f6b0e/attachment.htm>


More information about the erlang-questions mailing list