@param string $base64String

@return \SplFileInfo
762532
public static function createFileInfo(string $base64String): \SplFileInfo
    {
        preg_match('/data:(.*);/', $base64String, $matchMime);
        preg_match('/data:image\/(.*);base64/', $base64String, $matchExt);

        $fileName = sprintf('/%s.%s', uniqid(), $matchExt[1]);
        $outputFile = sys_get_temp_dir() . $fileName;
        $fileResource = fopen($outputFile, 'wb');
        $base64Data = explode(',', $base64String);

        fwrite($fileResource, base64_decode($base64Data[1]));
        fclose($fileResource);

        return new \SplFileInfo($outputFile);
    }
13844
public function fromBase64URL($data)
    {
        if ($remainder = strlen($data) % 4) {
            $data .= str_repeat('=', 4 - $remainder);
        }

        return base64_decode(strtr($data, '-_', '+/'));
    }
139305
public function serializerSimplexmlLoadString($xmlString){
    $numericTable = array();
    //commonly present restricted characters that can safely be replaced
    $numericTable['&'] = '&#38;';
    $entBitmask = defined('ENT_HTML5') ? ENT_QUOTES | ENT_HTML5 : ENT_QUOTES;
    $trans = get_html_translation_table(HTML_ENTITIES, $entBitmask);
    foreach ($trans as $k=>$v){
      $numericTable[$v]= "&#".ord($k).";";
    }
    $xmlString = strtr($xmlString, $numericTable);
    return simplexml_load_string($xmlString);
  }
1162054
@SuppressWarnings("unchecked")
        public static <T> T decode(String base64) {
                //BASE64Decoder decoder = new BASE64Decoder();
                try {
                        //byte[]               b    = decoder.decodeBuffer(base64);
                		byte[]               b    = Base64.decode(base64);
                        ByteArrayInputStream bais = new ByteArrayInputStream(b);
                        ObjectInputStream    ois  = new ObjectInputStream(bais);
                        return (T)ois.readObject();
                } catch (IOException | ClassNotFoundException e) {
                        throw new RuntimeException(e);
                }
        }
983638
public function ToXML($base64 = true)
	{
		return "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n"
			. "<file>\r\n"
			. "<name>".$this->Name."</name>\r\n"
			. "<size>".$this->Size."</size>\r\n"
			. "<type>".$this->Type."</type>\r\n"
			. "<Extension>".$this->Extension."</Extension>\r\n"
			. "<encoding>" . ($base64 ? "base64" : "none") . "</encoding>\r\n"
			. "<data>" . ($base64 ? base64_encode($this->Data) : $this->Data) . "</data>\r\n"
			. "</file>";
	}
373218
public function base64Decode(string $base64Encoded): string
    {
        if ($remainder = strlen($base64Encoded) % 4) {
            $base64Encoded .= str_repeat('=', 4 - $remainder);
        }

        return base64_decode(strtr($base64Encoded, '-_', '+/'));
    }
767332
public function base64Upload( string $base64_content ) : Image
	{
		$this->file = $base64_content;

		// data:image/png;base64,
		list( $head, $content ) = explode( ",", $this->file );
		$this->mediaType  = str_replace( ';base64', '', str_replace( 'data:', '', $head ) );
		$this->ext        = strtolower( explode( '/', $this->mediaType )[1] ); // todo 单独来个方法设置
		$this->originName = "base64";
		if( !in_array( $this->ext, $this->allowFileType ) ){
			throw new \Exception( "不支持该类型" );
		}

		// 生成随机名字
		$this->fileName = Random::randStr( $this->randNameLength );

		// 目标全名
		$target_file_name = "{$this->targetFolder}/{$this->fileName}.{$this->ext}";

		// 移动原图到存放目录
		$move_result = file_put_contents( $target_file_name, base64_decode( $content ) );
		if( $move_result == false ){
			throw new \Exception( "移动文件失败" );
		}
		// 源文件信息
		$this->originFileInfo = $this->getImageInfoFormatData( $target_file_name );
		return $this;
	}
449912
public function base64Encode(string $base64Decoded): string
    {
        $base64Decoded = base64_encode($base64Decoded);
        $base64Decoded = rtrim(strtr($base64Decoded, '-_', '+/'), '=');

        return $base64Decoded;
    }
171229
public static function encodeBase64Header($str,
        $charset,
        $lineLength = self::LINELENGTH,
        $lineEnd = self::LINEEND)
    {
        $prefix = '=?' . $charset . '?B?';
        $suffix = '?=';
        $remainingLength = $lineLength - strlen($prefix) - strlen($suffix);

        $encodedValue = self::encodeBase64($str, $remainingLength, $lineEnd);
        $encodedValue = str_replace($lineEnd, $suffix . $lineEnd . ' ' . $prefix, $encodedValue);
        $encodedValue = $prefix . $encodedValue . $suffix;
        return $encodedValue;
    }
388618
protected function makeJsonSafe($data, $base64 = true)
    {
        if (is_array($data)) {
            foreach ($data as $key => $value) {
                $data[$key] = $this->makeJsonSafe($value, $base64);
            }
        }
        if (!$this->isJsonEncodable($data)) {
            if (true === $base64) {
                return 'base64:' . base64_encode($data);
            } else {
                return '--non-parsable-data--';
            }
        }

        return $data;
    }
1046621
public static function safeBase64Decode($string)
    {
        $data = str_replace(array('-', '_'), array('+', '/'), $string);
        $mod4 = strlen($data) % 4;
        if ($mod4) {
            $data .= substr('====', $mod4);
        }

        return static::base64Decode($data);
    }
1288082
public function getBase64()
    {
        if ($this->owner->exists()) {
            $file = $this->owner->getFullPath();
            $mime = mime_content_type($file);
            $fileContent = file_get_contents($file);
            return "data://$mime;base64," . base64_encode($fileContent);
        }
        
        return null;
    }
518451
public function isBase64()
    {
        if (!is_string($this->data)) {
            return false;
        }

        return base64_encode(base64_decode($this->data)) === $this->data;
    }
1325622
public function getOneNonExpiredByBase64EncodedId($base64EncodedId)
    {
        $qb = $this->createDefaultQueryBuilder()
            ->setMaxResults(1);
        $this
            ->addIdFilter($qb, base64_decode($base64EncodedId))
            ->addNonExpiredFilter($qb);

        return $qb->getQuery()->getOneOrNullResult();
    }
54059
private function baseDecode($string)
    {
        $b      = 61;
        $base   = '123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
        $limit  = strlen($string);
        $result = strpos($base, $string[0]);
        for ($i = 1; $i < $limit; ++$i) {
            $result = $b * $result + strpos($base, $string[$i]);
        }

        return $result;
    }
102288
public static function base64UrlSafeEncode($s)
    {
        $s = base64_encode($s);
        $s = str_replace('+', '-', $s);
        $s = str_replace('/', '_', $s);
        $s = str_replace('=', '', $s);
        return ($s);
    }
908176
public function getBase64Source(){
                $Fullpath = $this->owner->getFullPath();

                $cache = SS_Cache::factory('Base64Image');
                $cachekey = md5($Fullpath);
                if(!($Base64Image = $cache->load($cachekey))){
                    $Base64Image = base64_encode(file_get_contents($Fullpath));
                    $cache->save($Base64Image);
                }

                $type = strtolower($this->owner->getExtension());

                return "data:image/".$type.";base64,".$Base64Image;
        }