phpwordpresshash

Decrypt hashed string generated with wp_hash()


I'd like to hash an ID in a PHP template as it will be used in my javascript code and should not be readable for website users. I'm using Wordpress' wp_hash() function to hash the string (not wp_hash_password()).

Later the hashed string is processed by PHP again (via ajax) and should be decrypted. Is there a way to decrypt such hashes?


Solution

  • First, I think you need to look at the difference between encryption and hashing.

    If the ID needs to be decryptable, you need to use encryption. The hash is not suitable for this task.

    Because you did not describe the purpose of the ID or how your process works, I'm unfortunately unable to provide further advice. Maybe you shouldn't even encrypt the ID, or you should use a completely different solution.