I need to store a Hash (MD5/SHA1) into the DB. what is the best way to
store it in DB?
- binary string of 16/20 chars
- 32 byte hex
- base64 encoded string
Well, I am not able to store the raw 16byte binary string into the DB, not
sure if it is possible.
My C/CPP program needs to read Hash from the DB and compare it with the
client provided hash. The client is a web application, written in java.
pl, suggest what should i do?
thanks in adv
-nilesh
> I need to store a Hash (MD5/SHA1) into the DB. what is the best way to
> store it in DB?
[quoted text clipped - 5 lines]
> Well, I am not able to store the raw 16byte binary string into the DB, not
> sure if it is possible.
It is possible, but you'll need to use a binary data type for the column.
Personally, I find this too much hassle though. I want to be able to
manually verify the first few hashes to make sure my algorithm is correct.
Of the other two, it doesn't matter which you use. The 32 character hex
representation is easier to implement though, if you don't have a utility
class for one of the other ready.
> My C/CPP program needs to read Hash from the DB and compare it with the
> client provided hash. The client is a web application, written in java.
>
> pl, suggest what should i do?
It doesn't matter exactly what you do. My preferences are these:
1. SHA-1 hashing algorithm, as it is the hash Dutch banks use.
(I live in the Netherlands)
2. Use a base64 encoding. Slightly more expensive than hex encoding, but
password verification doesn't occur that often. Thus my default choice
is to optimize storage space.

Signature
Oscar Kind http://home.hccnet.nl/okind/
Software Developer for contact information, see website
PGP Key fingerprint: 91F3 6C72 F465 5E98 C246 61D9 2C32 8E24 097B B4E2