Today, We want to share with you base64 encode php script.In this post we will show you base64 encrypt decrypt php, hear for base64 decode php online we will give you demo and example for implement.In this post, we will learn about How to convert base64 to image and save in folder php? with an example.
Base64 Encode and Decode String in PHP
simple Encodes the given data with MIME base64 using PHP. as well as PHP Base64-encoded data takes about 33% more some space than the original data contents.
PHP base64_encode()
base64_encode — Encodes data with MIME base64
Function
string base64_encode ( string $data );
Example 1:
<?php function base64url_encode($text){ $base64 = base64_encode($text); $base64url = strtr($base64, '+/=', '-_,'); return $base64url; } function base64url_decode($text){ $base64url = strtr($text, '-_,', '+/='); $base64 = base64_decode($base64url); return $base64; } ?>
A simple code: for base64 encode php
$source = "ANhfDSdieoruDKLFdifjfmcvDFKOdffeddfgfd898465DFGKGfogjfkgkfgkmcfg=="; $code = base64_decode($source); eval($code);
Example 2:
<?php $str = 'Welcome To Pakainfo.com'; echo base64_encode($str); ?>
Encoding & Decoding PHP Code
Example Encoding:
<?php $source_script = 'Welcome To Pakainfo.com'; $encoded = str_rot13($source_script); $decoded = str_rot13(str_rot13($source_script)); echo $encoded ."\n"; echo $decoded; ?>
Example Decoding:
<?php $source_script = 'Welcome To Pakainfo.com'; $encoded = base64_encode($source_script); $decoded = base64_decode($encoded); echo $encoded ."\n"; echo $decoded; ?>
Deflate and inflate with gzdeflate() & gzinflate()
Example gzdeflate():
<?php $source_script = 'Welcome To Pakainfo.com'; $compressed = gzdeflate($source_script); $uncompressed = gzinflate($compressed); echo $compressed ."\n"; echo $uncompressed; ?>
Example gzinflate():
<?php $source_script = 'Welcome To Pakainfo.com'; $compressed = gzdeflate($source_script, 9); $uncompressed = gzinflate($compressed, strlen($source_script)); echo $compressed ."\n"; echo $uncompressed; ?>
I hope you get an idea about Base64 PHP File Encoder.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.
Related FAQ
Here are some more FAQ related to this Article: