gennyble / hext

A Binary File Markup Language
ISC License
24 stars 0 forks source link

Checmsum and Length Autofilling #2

Open gennyble opened 4 years ago

gennyble commented 4 years ago

A lot of Network protocols require a checksum, but who wants to do that manually. There should/could be an option to specify which byte (or maybe line? Some kind of marker) to insert/replace a checksum of a specific kind.

gennyble commented 3 years ago

Here's the rough plan:

Do a first pass looking for the notation for inserting the checksum/length there. Something like @16:checksum(span) where span is similar to $start(span) <data> $end(span). During the second pass parse the tree you now have and try not to recur to hard?

gennyble commented 2 years ago

Hello, last-year-me.

I'm still worried that this is some kind of scope creep. Right now I'm of the mind that it's a good idea, still, we want hext to be useful and this'd be useful. I'm not big on the notation I chose for checksum up there, but I like the idea. A span and then a marker to say "put the checksum here and make it N bytes". The number of bytes is probably specified by the algorithm, but I'd very much like it to be explicit/

Maybe a notation of {checksum <algorith> for <span>} would be good. That's the marker and sits where the checksum should go. I like the span notation, but maybe change it to ~start <name> and ~end <name>. They'd have to stand on their own line, like this.

~start header
FD 13 .0100 .1000 {checksum crc32 for header}
~end header

(crc32 is a checksum algorithm, right?)

Not thrilled with the curly braces there, so maybe we'll have to think about that more. Very much like the start/end markers though. It also doesn't say how many bytes it's inserting.