I feel foolish asking this, but will the hash generated by SHA-1 or other encryp
ID: 647525 • Letter: I
Question
I feel foolish asking this, but will the hash generated by SHA-1 or other encryption methods ever have the possibility of containing a quote? Or any other characters that may be escaped such as ", ', and
I am attempting to make a non-MySQL database to hold values such as hashes (and yes, I am aware that it is not the most secure option for holding things such as passwords; this is just a private endevour for fun). I was planning to store the tables and data in JSON files, so that is why I need to know if I will need to escape some characters before storing the data.
Explanation / Answer
The hash output is a random string of a length specified by the function (that is 160 bits for SHA-1). It may contain any special characters, including e.g. white space.
It is more common to encode the value in hex than to use quoting of special characters are special characters are very common in hash output (minority of characters would be ASCII if no encoding was applied). Encoding in hex also helps in making the length of the output of hash function fixed number of characters, which is useful. Occasionally base64 encoding (or its variant) is used instead of hex. For the best use of storage, it may be good to store the field in binary and just apply the encoding (e.g. hex) when displaying the value of the field.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.