FOF30\Encrypt\Totp::getUrl PHP Метод

getUrl() публичный Метод

Returns a QR code URL for easy setup of TOTP apps like Google Authenticator
public getUrl ( string $user, string $hostname, string $secret ) : string
$user string User
$hostname string Hostname
$secret string Secret string
Результат string
    public function getUrl($user, $hostname, $secret)
    {
        $url = sprintf("otpauth://totp/%s@%s?secret=%s", $user, $hostname, $secret);
        $encoder = "https://chart.googleapis.com/chart?chs=200x200&chld=Q|2&cht=qr&chl=";
        $encoderURL = $encoder . urlencode($url);
        return $encoderURL;
    }

Usage Example

Пример #1
0
 /**
  * @return  void
  */
 public function testGetUrl()
 {
     $this->assertEquals('https://chart.googleapis.com/chart?chs=200x200&chld=Q|2&cht=qr&chl=otpauth%3A%2F%2Ftotp%2FJohnnieWalker%40example.com%3Fsecret%3DKREECVCJKNKE6VCBJRGFSU2FINJEKVA', $this->totp->getUrl('JohnnieWalker', 'example.com', 'KREECVCJKNKE6VCBJRGFSU2FINJEKVA'));
 }