3 ms·
Two things, one which supports the other: First is Concise Encoding, a secure, binary and text ad-hoc data format with full type support: https://concise-encod
by kstenerud 4y ago
Two things, one which supports the other:
First is Concise Encoding, a secure, binary and text ad-hoc data format with full type support: https://concise-encoding.org/ https://concise-encoding.org/
Example of the text format:
c1
{
"string" = "Strings support escape sequences: \n \t \[1f415]"
"boolean" = true
"binary int" = -0b10001011
"octal int" = 0o644
"decimal int" = -10000000
"hex int" = 0xfffe0001
"very long int" = 100000000000000000000000000000000000009
"decimal float" = -14.125
"hex float" = 0x5.1ec4p+20
"very long flt" = 4.957234990634579394723460546348e+100000
"not-a-number" = nan
"infinity" = inf
"list" = [1 2.5 "a string"]
"map" = {"one"=1 2="two" "today"=2020-09-10}
"bytes" = |u8x 01 ff de ad be ef|
"int16 array" = |i16 7374 17466 -9957|
"uuid" = f1ce4567-e89b-12d3-a456-426655440000
"date" = 2019-07-01
"time" = 18:04:00.948/Europe/Prague
"timestamp" = 2010-07-15/13:28:15.415942344
"null" = null
"media" = |application/x-sh 23 21 2f 62 69 6e 2f 73 68 0a 0a
65 63 68 6f 20 68 65 6c 6c 6f 20 77 6f 72 6c 64 0a|
}
Almost all existing data formats are horribly insecure and ripe for exploitation (many of them are already). And they can't be fixed because the formats aren't versioned.
-----------------
But describing the data format was painful because most existing metalanguages are only for describing textual grammars, and the few that support binary aren't really suited for documenting for human consumption.
So I'm putting the finishing touches on Dogma ( https://github.com/kstenerud/dogma/blob/master/dogma_v1.md https://github.com/kstenerud/dogma/blob/master/dogma_v1.md ), a modernized BNF-style metalanguage with better expressiveness and binary grammar support.
For example:
A UDP packet consists of a source port, a destination port, a length, a checksum, and a body. The length field refers to the size of the entire packet, not just the body.
udp_packet = src_port
& dst_port
& uint(16, var(length,8~) )
& checksum
& body(length - 8) # subtract header from length to get body length
;
src_port = uint(16,~);
dst_port = uint(16,~);
checksum = uint(16,~);
body(length) = uint(8,~){length};