what is encription and decription in php, (encode and decode).


md5() function convert the string into hash of a string (encripted format).

File name : index.php

<?php
$str = "itechtuto";
echo md5($str);
?>

Output :-

c1ed2c5ddc8fe77f58debfa699eac293

base64_encode

string base64_encode ( string $data )
Encodes the given data with base64.
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
Base64-encoded data takes about 33% more space than the original data.

File name : index.php

<?php
$str = 'This is an encoded string';
echo base64_encode($str);


$id = 7;
$enc_id = base64_encode($id);
echo $enc_id;
?>

Output :-

VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==

base64_decode

base64_decode ? Decodes data encoded with MIME base64

File name : index.php

<?php
$str = 'VGhpcyBpcyBhbiBlbmNvZGVkIHN0cmluZw==';
echo base64_decode($str);



$id = "XafS=";
$enc_id = base64_decode($id);
echo $enc_id;
?>

Output :-

This is an encoded string

Hash

// insert password in db
echo password_hash("habib", PASSWORD_DEFAULT);


output : $2y$10$GZo/udmUI7WJs5DiGwJtuub77xo6R026mVl3xmrQwExivnnDUhMTi

// verify password
$this->load->library('bcrypt');
$email = $this->input->post('email', true)
$password = $this->input->post('password', true)
$data = $this->Auth_model->get_user($email);
$this->bcrypt->check_password($password, $data->password);





Previous Next


Trending Tutorials




Review & Rating

0.0 / 5

0 Review

5
(0)

4
(0)

3
(0)

2
(0)

1
(0)

Write Review Here