something else wrote:
yeah all chars are inside base64 alaphabet 🙁
and my above code didnt work :/
php[net] base 64
Since I'm not able to upgrade PHP to the latest version, I needed a way to check if some data had actually been encoded before trying to decode it. Here is the function I've used; I hope it helps someone.
<?php
/**
* Check a string of base64 encoded data to make sure it has actually
* been encoded.
*
* @param $encodedString string Base64 encoded string to validate.
* @return Boolean Returns true when the given string only contains
* base64 characters; returns false if there is even one non-base64 character.
*/
function checkBase64Encoded($encodedString) {
$length = strlen($encodedString);
// Check every character.
for ($i = 0; $i < $length; ++$i) {
$c = $encodedString[$i];
if (
($c < '0' || $c > '9')
&& ($c < 'a' || $c > 'z')
&& ($c < 'A' || $c > 'Z')
&& ($c != '+')
&& ($c != '/')
&& ($c != '=')
) {
// Bad character found.
return false;
}
}
// Only good characters found.
return true;
}
?>
try with imap 😀 .. might work'
fast check shorted name ...
<?php
function checkBase64($encodedString) {
$length = strlen($encodedString);
// Check every character.
for ($i = 0; $i < $length; ++$i) {
$c = $encodedString[$i];
if (
($c < '0' || $c > '9')
&& ($c < 'a' || $c > 'z')
&& ($c < 'A' || $c > 'Z')
&& ($c != '+')
&& ($c != '/')
&& ($c != '=')
) {
// Bad character found.
return false;
}
}
// Only good characters found.
return true;
}
$text="ZGVtbyB0ZXh0";
if (checkBase64($text)) {echo'text is encoded';}
else { echo'text is not base64 :)';}
?>
This is ten percent luck, twenty percent skill
Fifteen percent concentrated power of will
Five percent pleasure, fifty percent pain
😂And a hundred percent reason to remember the name!