Reputation: 3169
I need to perform an intensive computation based on an input value, which is an ASCII string with a maximum of 100 chars. Since the computation is intensive and quite long, I'd like to cache my results for a certain input value.
My intensive computation result would be perfectly cacheable (the same input always yields the same output) if it weren't for a detail: I can't use the input value as a key for my cache, because it's a sensitive string and I am not allowed to store it anywhere for longer than it's strictly needed.
I thought about using a cryptographic hash function and using the hashed value, but I can't admit collisions; I can expand the hash function codomain to be larger, even far larger ( a 10000 chars hash would be fine) than the input value length, but I need the hash function to be be both perfect and one-way.
I found examples of either kind of hash function, not of a function which is both.
Any idea?
Upvotes: 0
Views: 274
Reputation: 3891
You can use any asymmetric cypher (for example, RSA) without decryption key. By this way, you can encrypt message, and it would be without collision, since it theoretically can be decrypted back with decryption key. But practically it cannot be decrypted, since decryption key is missing. So, your transform would be one-way, and without collisions.
But, important: Don't use modern 2-level schemes, where encrypted random session key. This mechanism does not guarantee collision-free. Instead, split your message to blocks of appropriate size, and encrypt each block in ECB mode.
Upvotes: 4