-module(detect_demo). -export([run/0]). run() -> application:ensure_all_started(gmserialization), code:add_path("asn1"), Sample = {'GajumaruData', 10, 1, {templateFields, [ {'TemplateField', <<"foo">>, {intValue, 42}}, {'TemplateField', <<"bar">>, {binaryValue, <<"hello">>}} ]}}, {ok, Der} = 'GajumaruSerialization':encode('GajumaruData', Sample), io:format("DER first byte: ~p (0x~2.16.0B)~n", [binary:at(Der,0), binary:at(Der,0)]), {ok, _Dec} = 'GajumaruSerialization':decode('GajumaruData', Der), io:format("DER roundtrip OK~n"), Legacy = gmser_chain_objects:serialize(account, 1, [{foo,int},{bar,binary}], [{foo,42},{bar,<<"hello">>}]), <> = binary:part(Legacy,0,1), <> = binary:part(Der,0,1), io:format("Legacy 0x~2.16.0B (>= 0xC0 -> legacy: ~p)~n", [L0, L0 >= 16#C0]), io:format("DER 0x~2.16.0B (< 0xC0 -> new DER: ~p)~n", [D0, D0 < 16#C0]), ok.