mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-25 11:20:03 +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()
|
||||
{
|
||||
return $this->hash->getHash();
|
||||
return clone $this->hash;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1462,4 +1462,12 @@ class Hash
|
||||
|
||||
return $temp;
|
||||
}
|
||||
|
||||
/**
|
||||
* __toString() magic method
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->getHash();
|
||||
}
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ abstract class RSA extends AsymmetricKey
|
||||
*/
|
||||
public function getMGFHash()
|
||||
{
|
||||
return $this->mgfHash->getHash();
|
||||
return clone $this->mgfHash;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -170,17 +170,17 @@ HERE;
|
||||
->withSaltLength(5)
|
||||
->withMGFHash('sha512');
|
||||
|
||||
$this->assertSame('sha1', $rsa->getHash());
|
||||
$this->assertEquals('sha1', $rsa->getHash());
|
||||
$this->assertSame(5, $rsa->getSaltLength());
|
||||
$this->assertSame('sha512', $rsa->getMGFHash());
|
||||
$this->assertEquals('sha512', $rsa->getMGFHash());
|
||||
|
||||
$rsa = $rsa
|
||||
->withHash('sha512')
|
||||
->withSaltLength(6)
|
||||
->withMGFHash('sha1');
|
||||
|
||||
$this->assertSame('sha512', $rsa->getHash());
|
||||
$this->assertEquals('sha512', $rsa->getHash());
|
||||
$this->assertSame(6, $rsa->getSaltLength());
|
||||
$this->assertSame('sha1', $rsa->getMGFHash());
|
||||
$this->assertEquals('sha1', $rsa->getMGFHash());
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user