For this application, any encryption algorithm is in order. You can pack the values ββas you like, as long as they are repeatable. One common method is to pack the fields into a string the same way you encode them into the URL for the GET request (name = value).
To compute the hash, create secret text that can be whatever you want. It must be at least 12 bytes long. Calculate the privacy hash combined with the packed fields and add this to the end.
So, let's say you chose MD5, the secret of JS90320ERHe2 , and you have these fields:
first_name = Jack last_name = Smith other_field = 7=2
First, the URL encodes it:
first_name=Jack&last_name=Smith&other_field=7%3d=2
Then calculate the MD5 hash
JS90320ERHe2first_name=Jack&last_name=Smith&other_field=7%3d=2
This is 6d0fa69703935efaa183be57f81d38ea . Final encoded field:
first_name=Jack&last_name=Smith&other_field=7%3d=2&hash=6d0fa69703935efaa183be57f81d38ea
So what do you pass to the user. To test it, remove the hash from the end, calculate the MD5 hash, combining what remains with this secret, and if the hashes match, this field has not been changed.
No one can compute their own valid MD5 because they donβt know that the string prefix should be.
Note that an adversary can reuse any old valid value. They simply cannot create their own value set from scratch, or modify an existing one and test it for proper operation. Therefore, make sure that you include something in the information so that you can verify that it is suitable for the purpose that it used.