hashcat Forum
Efficient way to store hashes in database ? - Printable Version

+- hashcat Forum (https://hashcat.net/forum)
+-- Forum: Misc (https://hashcat.net/forum/forum-15.html)
+--- Forum: General Talk (https://hashcat.net/forum/forum-33.html)
+--- Thread: Efficient way to store hashes in database ? (/thread-1440.html)



Efficient way to store hashes in database ? - Mem5 - 08-07-2012

Hi,

What is the best way (for fastest request / response time) to store hashes in a mysql database ?

I saw UNHEX() which convert hexa in binary, then the column can store only digits, which I think is faster.

What to you suggest ?

Thanks.


RE: Efficient way to store hashes in database ? - undeath - 08-07-2012

if you only need to store user passwords, store a base64 encoded string of the hash.


RE: Efficient way to store hashes in database ? - Bitweasil - 08-07-2012

I wouldn't use MySQL if "fastest request/response time" were a concern.

If you wish to do this, storing them as a binary blob with prepared statements is probably the best option.

However, I would seriously suggest looking at a key value store system for handling this type of workload. It's much better suited to it than a full SQL database.


RE: Efficient way to store hashes in database ? - unix-ninja - 08-07-2012

Encoding the hashes in base64 will not get you the fastest processing time for storage and retrieval. In-fact, it will hurt your stats for sure.

There are MANY factors to consider with MySQL, including the table engines, table structures, and usage of the tables and data.

If you want to gain a little performance in storage, don't convert the values to hex, use hex literals instead. For example:

Code:
insert into table (hex_col) values (0xHEXVALUE);

Additionally, depending on what this table will be used for and how the data will be used, you could try to optimize it by using memory tables to gain significant performance.

The thing to remember here, though, is that everything is relative.


RE: Efficient way to store hashes in database ? - Mem5 - 08-11-2012

Thank you for your answer.

@unix-ninja : when you suggest :
Code:
insert into table (hex_col) values (0xHEXVALUE);
what is the type of the column 'hex_col' ?


RE: Efficient way to store hashes in database ? - twitty - 08-16-2012

As Bitweasil said, MySQL is too slow. Try key/value as he suggested. I myself would use at MongoDB because it already is very efficient and it also has very nice support and there are many examples/lines of code flying around. You can also look at memcacheDB, Redis or other NoSQL database.