when we pass a paramter in Url, the paramter is visible. sometime it is privacy.
so how to encrypt the parameter in codeigniter.
like http://localhost/ani_3TIA/mahasiswa/edit/5 , i want to encrypt the "5" .
Add another VARCHAR field to your table, named "secret_id".
If you insert a record, store a random string into that field. You can use CI's string helper.
In your url's, don't use the record id, but instead the secret_id.
If you want to be really safe, check if the random string already exists in your table before the record is inserted. If so, generate a new random string.
Hope this will help.
Encode:
1. XOR with a "SECRET" number (stored in cogfig).
2. Encode with base64/base26 (for example).
Decode:
1. Decode with base64/base26 (for example).
2. XOR with a "SECRET" number (stored in cogfig).
In this case you no need to generate (with checking for duplicated values) and store addition data and values will be unique*.
--
* Depends of encode/decode algorithm.
See the PHP methods urlencode and urldecode.
thankyou for the explanation guys, i will try it