0

I am new in Codeigniter. I want to encrypt full URL like below example.

For example this is my url www.example.com & my controller is home, so full url is www.example.com/home

Now I want to encrypted all controller, function like below

www.example.com/5115784bef2514430e7f74d9a71d4142a942efb0f7cc428626bda7633326f9d015fbacc60d93cd6b858f9b6e05c1e56263acb24297cecc720467eb4f222d81e5hdn5B

I can encrypt and decrypt the text well, but I just don't get how I can decrypt from url & make understand which controller or function is called, I want to decrypted everything after base_url.

Please don't suggest using a common controller, because I already know that & any how common controller hides everything so it's not required for the encryption I believe.

3 Answers 3

0

Well i never encrypt any URL before but you can use a php function url_encode

And "str_replace" function.

the reason for using "str_replace" beacause url_encode only encode special character in URL.

Hope I help some.

Try the code below.

urlencode(str_replace("your_domain.com/YourCOntrollerName/YourMethodName" , "SM5ah52" , yor_domain.com . "YourCOntrollerName/YourMethodName/YOuData"));

If not this. There is an library in CI Framework called Encryption. You can get help from there Encryption.

Sign up to request clarification or add additional context in comments.

Comments

0

Go with URI Routing and define one controller to decode whatever you are passing, and call proper controller / method from it.

2 Comments

Somehow its means that I must have to use one common controller?
one controller to redirect "traffic" among others. or you can do some kind of encryption which allows you to split it between many controllers. for example if first character of link is A -> direct traffic to controller A, and so on... multiple solutions.
0

You can use URI Routing with regular expressions.

$route["other_controllers/method"] = "other_controllers/method"; //you can add this kind of lines to not to affect other controllers
$route["([a-zA-Z0-9]+)"] = "home/decrypt/$1";

In the home controller, You can

  1. Redirect to the page

Or

  1. Load a view
public function decrypt($token){
   //geting the page according to the token from database.
   $desired_page = $this->some_model->get_page($token);

   //if you want to redirect
   redirect($desired_page);

   //if you want to load a view
   $this->load->view($desired_page);
}

2 Comments

Thanks a lot for mentioning proper way but, Somehow its means that I must have to use one common controller to decode, right?
I didn't get this - common controller its hide everything so its not required the encryption. As I know, There could be only one gateway to decrypt the string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.