Supposed that I get an ID from third party (in this case, Telegram ID which is the range $-2^{31}$ to $2^{31}-1$). I want to store the ID securely and privately into my database by hashing it. I don't really care what the ID is, but I do really want to store the ID uniquely without actually storing the real data.
The problem is the entropy is pretty small (32-bit). Any people can get the real ID by brute forcing it. Also it is impossible to ask user to create a passphrase (or something like that) to make a derivative key, since I only get data from API and not interacting to it. I tried to figure out salting it, but since the main problem is the entropy is too small, I don't think it might work as expected.
HashIds is not a solution because the ID comes from third party.
How should I store the hash so that the hash won't be easily bruted-force? Currently, I am using SHA-512 to hash the ID.
Edit: for clarification
- I can't store plain ID to database so that I must hash it
- I don't need to recover original ID, but I need to check whether the hashes ID exists or not in DB, regardless the original ID
- This has nothing to do with user. Yes it was the user ID from third party, but it is no way for user interacting with it. Thus, it is impossible to ask user for a pass phrase or something like that.
To sum up, I need to hash the ID and making it harder to brute force. Is it possible even if attacker try to brute force the entire 32 bit entropy?