File: MD5Test.php

package info (click to toggle)
php-phpseclib 2.0.48-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,744 kB
  • sloc: php: 11,985; sh: 66; xml: 49; makefile: 23
file content (52 lines) | stat: -rw-r--r-- 1,437 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/**
 * @author    Andreas Fischer <bantu@phpbb.com>
 * @copyright 2012 Andreas Fischer
 * @license   http://www.opensource.org/licenses/mit-license.html  MIT License
 */

use phpseclib\Crypt\Hash;
use PHPUnit\Framework\Attributes\DataProvider;

class Unit_Crypt_Hash_MD5Test extends Unit_Crypt_Hash_TestCase
{
    public function getInstance()
    {
        return new Hash('md5');
    }

    /**
     * @dataProvider hashData()
     */
    #[DataProvider('hashData')]
    public function testHash($message, $result)
    {
        $this->assertHashesTo($this->getInstance(), $message, $result);
    }

    public static function hashData()
    {
        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'),
        );
    }

    /**
     * @dataProvider hmacData()
     */
    #[DataProvider('hmacData')]
    public function testHMAC($key, $message, $result)
    {
        $this->assertHMACsTo($this->getInstance(), $key, $message, $result);
    }

    public static function hmacData()
    {
        return array(
            array('', '', '74e6f7298a9c2d168935f58c001bad88'),
            array('key', 'The quick brown fox jumps over the lazy dog', '80070713463e7749b90c2dc24911e275'),
        );
    }
}