2012-08-20 11:49:41 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2014-02-15 18:57:49 +00:00
|
|
|
* @author Andreas Fischer <bantu@phpbb.com>
|
2014-12-09 23:02:44 +00:00
|
|
|
* @copyright 2012 Andreas Fischer
|
2014-02-15 18:57:49 +00:00
|
|
|
* @license http://www.opensource.org/licenses/mit-license.html MIT License
|
2012-08-20 11:49:41 +00:00
|
|
|
*/
|
|
|
|
|
2014-12-17 00:16:54 +00:00
|
|
|
use phpseclib\Crypt\Hash;
|
|
|
|
|
2014-06-01 19:13:20 +00:00
|
|
|
class Unit_Crypt_Hash_MD5Test extends Unit_Crypt_Hash_TestCase
|
2012-08-20 11:49:41 +00:00
|
|
|
{
|
2014-02-15 18:57:49 +00:00
|
|
|
public function getInstance()
|
|
|
|
{
|
2014-12-17 00:16:54 +00:00
|
|
|
return new Hash('md5');
|
2014-02-15 18:57:49 +00:00
|
|
|
}
|
2012-08-20 11:49:41 +00:00
|
|
|
|
2014-02-15 18:57:49 +00:00
|
|
|
/**
|
2015-03-29 16:07:17 +00:00
|
|
|
* @dataProvider hashData()
|
|
|
|
*/
|
2014-02-15 18:57:49 +00:00
|
|
|
public function testHash($message, $result)
|
|
|
|
{
|
|
|
|
$this->assertHashesTo($this->getInstance(), $message, $result);
|
|
|
|
}
|
2012-08-20 11:49:41 +00:00
|
|
|
|
2015-07-15 01:52:31 +00:00
|
|
|
public static function hashData()
|
2014-02-15 18:57:49 +00:00
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('', 'd41d8cd98f00b204e9800998ecf8427e'),
|
|
|
|
array('The quick brown fox jumps over the lazy dog', '9e107d9d372bb6826bd81d3542a419d6'),
|
|
|
|
array('The quick brown fox jumps over the lazy dog.', 'e4d909c290d0fb1ca068ffaddf22cbd0'),
|
|
|
|
);
|
|
|
|
}
|
2012-08-20 11:49:41 +00:00
|
|
|
|
2014-02-15 18:57:49 +00:00
|
|
|
/**
|
2015-03-29 16:07:17 +00:00
|
|
|
* @dataProvider hmacData()
|
|
|
|
*/
|
2014-02-15 18:57:49 +00:00
|
|
|
public function testHMAC($key, $message, $result)
|
|
|
|
{
|
|
|
|
$this->assertHMACsTo($this->getInstance(), $key, $message, $result);
|
|
|
|
}
|
2012-08-20 11:49:41 +00:00
|
|
|
|
2015-07-15 01:52:31 +00:00
|
|
|
public static function hmacData()
|
2014-02-15 18:57:49 +00:00
|
|
|
{
|
|
|
|
return array(
|
|
|
|
array('', '', '74e6f7298a9c2d168935f58c001bad88'),
|
|
|
|
array('key', 'The quick brown fox jumps over the lazy dog', '80070713463e7749b90c2dc24911e275'),
|
|
|
|
);
|
|
|
|
}
|
2012-08-20 11:49:41 +00:00
|
|
|
}
|