mirror of
https://github.com/RobThree/TwoFactorAuth.git
synced 2026-10-09 21:35:48 +00:00
23 lines
561 B
PHP
23 lines
561 B
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace RobThree\Auth\Providers\Qr;
|
|
|
|
use function base64_decode;
|
|
use function preg_match;
|
|
|
|
trait HandlesDataUri
|
|
{
|
|
private function DecodeDataUri(string $datauri): ?array
|
|
{
|
|
if (preg_match('/data:(?P<mimetype>[\w\.\-\+\/]+);(?P<encoding>\w+),(?P<data>.*)/', $datauri, $m) === 1) {
|
|
return array(
|
|
'mimetype' => $m['mimetype'],
|
|
'encoding' => $m['encoding'],
|
|
'data' => base64_decode($m['data'], true),
|
|
);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|