Exemplo n.º 1
0
 /**
  * Create authentication URL.
  */
 public function createURL($user, $data = NULL)
 {
     if (is_null($data)) {
         return parent::createURL($user);
     } else {
         $toktype = $data["tokentype"];
         $key = $this->helperhex2b32($data["tokenkey"]);
         // Token counter should be one more then current token value,
         // otherwise it gets confused.
         $counter = $data["tokencounter"] + 1;
         $toktype = strtolower($toktype);
         if ($toktype == "hotp") {
             $url = "otpauth://{$toktype}/{$user}?secret={$key}&counter={$counter}";
         } else {
             $url = "otpauth://{$toktype}/{$user}?secret={$key}";
         }
         return $url;
     }
 }
Exemplo n.º 2
0
<?php

require_once "../lib/ga4php.php";
$ga = new GoogleAuthenticator("/dev/null");
echo "creating 10000 keys\n";
$oldkey = "";
$key = $ga->createBase32Key();
$hex = $ga->helperb322hex($key);
$url = $ga->createURL("someuser", $key);
system("qrencode -s 6 -o /tmp/file.unittest {$url}");
system("eog /tmp/file.unittest");
echo "key in hex: {$hex}\n";
//unlink("/tmp/file.unittest");