Example #1
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) );
 }
Example #2
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 */
     } elseif ($func == 'sha256') {
         $macLen = 32;
         /* 256 bit */
     } else {
         return false;
     }
     return OpenId\OpenId::randomBytes($macLen);
 }