public static function GetEncoding($list)
 {
     $pattern = '0';
     $multiplier = 1;
     foreach ($list as $member) {
         $pattern = Conversion::BinaryMultiply($pattern, Conversion::Binary($multiplier));
         //echo $pattern.'<br>';
         $pattern = Conversion::BinaryAdd($pattern, Conversion::Binary($member[1]));
         $multiplier = $member[0];
     }
     return $pattern;
 }
Beispiel #2
0
 public static function Decode($base64)
 {
     $binary_digits = '';
     $alignment = strpos(self::$symbols, substr($base64, 0, 1));
     if ($alignment === false) {
         return false;
     }
     if ($alignment > 0) {
         $alignment = 6 - $alignment;
     }
     $length = strlen($base64);
     for ($symbol_pos = 1; $symbol_pos < $length; $symbol_pos++) {
         $value = strpos(self::$symbols, substr($base64, $symbol_pos, 1));
         if ($value === false) {
             return false;
         } else {
             $binary_digits .= Conversion::Binary($value, 6);
         }
     }
     return substr($binary_digits, 0, strlen($binary_digits) - $alignment);
 }