mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-26 03:27:31 +00:00
Hash: add __toString() method
This commit is contained in:
parent
10ce0b9b21
commit
881fbd78ee
@ -388,7 +388,7 @@ abstract class AsymmetricKey
|
|||||||
*/
|
*/
|
||||||
public function getHash()
|
public function getHash()
|
||||||
{
|
{
|
||||||
return $this->hash->getHash();
|
return clone $this->hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1462,4 +1462,12 @@ class Hash
|
|||||||
|
|
||||||
return $temp;
|
return $temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* __toString() magic method
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->getHash();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -669,7 +669,7 @@ abstract class RSA extends AsymmetricKey
|
|||||||
*/
|
*/
|
||||||
public function getMGFHash()
|
public function getMGFHash()
|
||||||
{
|
{
|
||||||
return $this->mgfHash->getHash();
|
return clone $this->mgfHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -170,17 +170,17 @@ HERE;
|
|||||||
->withSaltLength(5)
|
->withSaltLength(5)
|
||||||
->withMGFHash('sha512');
|
->withMGFHash('sha512');
|
||||||
|
|
||||||
$this->assertSame('sha1', $rsa->getHash());
|
$this->assertEquals('sha1', $rsa->getHash());
|
||||||
$this->assertSame(5, $rsa->getSaltLength());
|
$this->assertSame(5, $rsa->getSaltLength());
|
||||||
$this->assertSame('sha512', $rsa->getMGFHash());
|
$this->assertEquals('sha512', $rsa->getMGFHash());
|
||||||
|
|
||||||
$rsa = $rsa
|
$rsa = $rsa
|
||||||
->withHash('sha512')
|
->withHash('sha512')
|
||||||
->withSaltLength(6)
|
->withSaltLength(6)
|
||||||
->withMGFHash('sha1');
|
->withMGFHash('sha1');
|
||||||
|
|
||||||
$this->assertSame('sha512', $rsa->getHash());
|
$this->assertEquals('sha512', $rsa->getHash());
|
||||||
$this->assertSame(6, $rsa->getSaltLength());
|
$this->assertSame(6, $rsa->getSaltLength());
|
||||||
$this->assertSame('sha1', $rsa->getMGFHash());
|
$this->assertEquals('sha1', $rsa->getMGFHash());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user