Reputation: 160
A list of contacts will be sent periodically on my server. Then I need to encode and store the hashes in a database with no initial values (only hashes). If I received contact twice the hash must be the same for this. At the moment I want to use AES encryption. To get the same hash twice it is necessary to use the same key and the same initialization vector, and it seems very unsafe. One of the solution, maybe , is generation key and iv from contact. It's better than use one key and iv for all contacts. Is it bad idea? Could you suggest another solution?
Upvotes: 0
Views: 55
Reputation: 3079
It depends on what do you want to do
store contacts encoded to retrieve clear data after, then you must use encryption: AES for example
or only some trace of them to see if you have them already : then a hash is sufficient. It is not reversible. SHA for example
Do you receive clear data ? then you have to do one of the two actions.
After, what do you want to do with that ?
with data encrypted, you can decrypt it
with hash, you can only see if you receive it again.
Is it the whole data, or only some part ? (password for example)
for hashing: How to hash some string with sha256 in Java?
Upvotes: 1