How to encrypt the parameter value in PHP


We are usually showing the get id in the URL. But it’s a huge mistake. Someone can change the parameter value and show other confidential data. Show to avoid such type of thing in this topic I am going to show you how to encrypt the URL id and how to use it again using the decrypt method.

Example: https://www.studentstutorial.com?id=2

Encrypt method:  https://www.studentstutorial.com?id=2sffs8uwhhpwww

<?php 

$str = 1; 

$customer_id= urlencode(base64_encode($str)); 

echo $decoded_id = base64_decode(urldecode($customer_id)); 

?>