I'm saving a log file in with each line corresponds to a log entry.
For integrity reason I'm adding at the end of each line a SHA256 hash of the previous line.
What is the best separator to use string to separate the log entry from the hash?
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It only takes a minute to sign up.Sign up to join this community
You don't absolutely need a separator as you know the size of the SHA-256 hash (32 bytes or 64 hexadecimals, for instance). If you really want a separator (because you want to change the hash size later on for instance) then you can use any separator that is not within the hexadecimal or base 64 alphabet, i.e. any character or outside the encoding of the hash.
So use a space (
_), or a
| or even
_|_ for some nice whitespace to keep things readable. You need to look for the separator or hash string starting at the end though, e.g. using a regular expression or some
lastIndexOf function. Make sure you raise a warning or error if the hash value has not been set, it could have been stripped off.