1<?php 2 3/** 4 * Class PassHash_test 5 * 6 * most tests are in auth_password.test.php 7 */ 8class PassHash_test extends PHPUnit_Framework_TestCase { 9 10 function test_hmac(){ 11 // known hashes taken from https://code.google.com/p/yii/issues/detail?id=1942 12 $this->assertEquals('df08aef118f36b32e29d2f47cda649b6', PassHash::hmac('md5','data','secret')); 13 $this->assertEquals('9818e3306ba5ac267b5f2679fe4abd37e6cd7b54', PassHash::hmac('sha1','data','secret')); 14 15 // known hashes from https://en.wikipedia.org/wiki/Hash-based_message_authentication_code 16 $this->assertEquals('74e6f7298a9c2d168935f58c001bad88', PassHash::hmac('md5','','')); 17 $this->assertEquals('fbdb1d1b18aa6c08324b7d64b71fb76370690e1d', PassHash::hmac('sha1','','')); 18 $this->assertEquals('80070713463e7749b90c2dc24911e275', PassHash::hmac('md5','The quick brown fox jumps over the lazy dog','key')); 19 $this->assertEquals('de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9', PassHash::hmac('sha1','The quick brown fox jumps over the lazy dog','key')); 20 21 } 22}