How do I choose a good magic number for my file format?

前端 未结 1 1166
轻奢々
轻奢々 2021-02-13 03:57

I am designing a binary file format from scratch, and I would like to include some magic bytes at the beginning so that it can be identified easily. How do I go about choosing w

1条回答
  •  孤城傲影
    2021-02-13 04:22

    Stay away from super-short magic numbers. Just because you're designing a binary format doesn't mean you can't use a text string for identifier. Follow that by an EOF char, and as an added bonus people who cat or type your binary file won't get a mangled terminal.

    0 讨论(0)
提交回复
热议问题