Editing

bytepeel set changes, adds and removes protobuf fields, CBOR/MessagePack values and DER elements, and writes the data back in the same outer format, with every other byte preserved. PATH=VALUE changes, PATH+=VALUE adds, --del PATH removes:

bytepeel [OPTIONS] set EDIT... [FILE]     # writes the new data to stdout
$ echo '1a 03 08 96 01' | bytepeel set 3.1=300000
1a 04 08 e0 a7 12

$ base64 -w0 msg.pb.gz | bytepeel set 2='"new name"' 3=sint:-5 > edited.b64

$ bytepeel set users.0.active=false ttl=null 'tags.0+="new"' --del legacy record.cbor > edited.cbor

$ echo '08 96 01 12 03 66 6f 6f' | bytepeel set 3+=42 --del 2
08 96 01 18 2a

$ bytepeel set '0.0.5.2.0.1="Test Root"' '0.0.4.1="2045-06-07T08:09:10Z"' ca.pem > test-ca.pem

$ echo 'a1 61 70 43 08 96 01' | bytepeel set p.1=300 'p.2+="hi"'   # protobuf in a CBOR byte string
a1 61 70 47 08 ac 02 12 02 68 69
  • Values: 42, sint:-2, 1.5, true, null, "text", hex:0a0b, b64:CgM=. A protobuf field keeps its wire type; a DER element keeps its tag.
  • Paths are the --get paths, and cross formats the same way: 2.0.0.5.2.0.1='"Test Root"' changes the common name of a base64 certificate in protobuf string field 2, and both the certificate's base64 and the protobuf around it are re-encoded.
  • Original style: hex keeps its spacing and case, base64 its alphabet and line width, PEM its label, gzip its header.
  • Verified: the output is decoded again and checked before it is written (REENCODE_VERIFY_FAILED otherwise).
  • Signatures are not updated. Editing a certificate invalidates its signature; that's fine for test fixtures, and you re-sign it if it must verify. JWTs are not editable.

The complete rules, per format, are in Editing rules.