CodeIgniter Forums
[ask] how to encrypt the url? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: [ask] how to encrypt the url? (/showthread.php?tid=69306)



[ask] how to encrypt the url? - me_octaviana - 11-02-2017

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" .


RE: [ask] how to encrypt the url? - Wouter60 - 11-03-2017

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.


RE: [ask] how to encrypt the url? - Vitaly83 - 11-03-2017

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.


RE: [ask] how to encrypt the url? - InsiteFX - 11-03-2017

See the PHP methods urlencode and urldecode.


RE: [ask] how to encrypt the url? - Narf - 11-03-2017

Read this (all of you): https://paragonie.com/blog/2015/09/comprehensive-guide-url-parameter-encryption-in-php


RE: [ask] how to encrypt the url? - InsiteFX - 11-03-2017

Thanks @Narf


RE: [ask] how to encrypt the url? - Wouter60 - 11-03-2017

(11-03-2017, 03:48 AM)Narf Wrote: Read this (all of you): https://paragonie.com/blog/2015/09/comprehensive-guide-url-parameter-encryption-in-php

This comes close to my idea, doesn't it?


RE: [ask] how to encrypt the url? - Narf - 11-03-2017

(11-03-2017, 06:04 AM)Wouter60 Wrote:
(11-03-2017, 03:48 AM)Narf Wrote: Read this (all of you): https://paragonie.com/blog/2015/09/comprehensive-guide-url-parameter-encryption-in-php

This comes close to my idea, doesn't it?

Yours is the closest one mentioned, yes. But every detail is important.


RE: [ask] how to encrypt the url? - me_octaviana - 11-04-2017

thankyou for the explanation guys, i will try it