1

I am passing the POST Id values through the URL like this

localhost:81/laravel/public/Application/1956458 

So I would like to encrypt the Keys in the address bar. How can i achieve that?

2 Answers2

2

There are some different ways to Encrypt your password,

1. Normal Encryption.

This is a strong AES encryption via the Mcrypt PHP extension,

$encrypted = Crypt::encrypt($id);

And also you can decrypt this encrypted values using this command,

$decrypted = Crypt::decrypt($encrypted);

2. Hashing A Password Using Bcrypt in Laravel.

This will create a hashed password. You may use it in your controller or even in a model.

$encrypted = Hash::make($id);

3. Direct Use Bcrypt.

In Laravel 5 you can directly encrypt the password using Bcrypt,

$encrypted = bcrypt($id);     
Mcfaith
  • 269
  • 4
  • 16
K.Suthagar
  • 2,226
  • 1
  • 16
  • 28
  • So anyone can decrypt my Id using this first commands? How is this secure? – user7354735 Dec 30 '16 at 02:39
  • @user7354735 to be able to decode the id you need no.1 or just use plain php functions. http://stackoverflow.com/questions/16600708/how-do-you-encrypt-and-decrypt-a-php-string http://stackoverflow.com/questions/1289061/best-way-to-use-php-to-encrypt-and-decrypt-passwords – Mujnoi Gyula Tamas Dec 30 '16 at 02:51
2

Use this code to encrypt and decrypt

$encrypt_val = Crypt::encrypt($value);
$decrypt_val = Crypt::decrypt($encrypt_val );

when you use decrypt please insertuse Illuminate\Contracts\Encryption\DecryptException;