Пример #1
0
 /**
  * Generates a secret key for given hash function, returns RAW key or false
  * if function is not supported
  *
  * @param string $func hash function (sha1 or sha256)
  * @return mixed
  */
 protected function _genSecret($func)
 {
     if ($func == 'sha1') {
         $macLen = 20;
         /* 160 bit */
     } else {
         if ($func == 'sha256') {
             $macLen = 32;
             /* 256 bit */
         } else {
             return false;
         }
     }
     return OpenID\OpenID::randomBytes($macLen);
 }
Пример #2
0
 /**
  * testing testRedirect
  *
  */
 public function testRandomBytes()
 {
     $this->assertSame('', OpenID::randomBytes(0));
     $x = OpenID::randomBytes(1);
     $this->assertTrue(is_string($x));
     $this->assertSame(1, strlen($x));
     $x = OpenID::randomBytes(1024);
     $this->assertTrue(is_string($x));
     $this->assertSame(1024, strlen($x));
 }