By 05/02/2014 3 Comments

How to Encode and Decode a String using Base64 scheme in PHP

What is Encode and Decode ?

  • That is used for security of our website
  • Encode and Decode functions are used to prevent the malicious string in PHP code
  • They are used to encrypt the PHP data and increase the security of that data
  • The main use of the encoding and decoding is increase the security of our website because that functions encrypts the actual data which can not be displayed by the user or hackers

base64_encode

  • It encodes the given data in base64
  • It takes about 33% more space than the original data
  • In the following example we use the base64_encode for encoding and decoding

base64_decode

  • It decodes the encoded data in original data
  • It is also called reverse process of encode

Encode and Decode a String using Base64 scheme using PHP.

<?php

function base64url_encode($Text) {

$base64 = base64_encode($Text); //pass parameter as a text, which will be encoded

$base64url = strtr($base64, '+/=', '-_,'); // this function add extra string and assign to a variable

return $base64url;

}

function base64url_decode($Text) {

$base64url = strtr($Text, '-_,', '+/=');

$base64 = base64_decode($base64url); // this function decode the encoded string, pass the encrypted encoded string as a argument to this function

return $base64;

}

?>






Posted in: PHP

Leave your valuable Comment

Have a natural attraction for women cosmetics and replica watches uk clothes, no
more than two for men the most attractive one, is to make their own driving experience, happy and can serve as the facade of the car, another is to highlight the taste edify sentiment rolex replica watch. The replica rolex is undoubtedly the most fashionable accessories, wear a suit to attend the activities, but also get a decent match on the replica watches .