Exemplo n.º 1
0
 public function testComputeHmacFromFile()
 {
     $filePath = CFile::createTemporary();
     CFile::write($filePath, "The quick brown fox jumps over the lazy dog.");
     $key = "key";
     $this->assertTrue(CHash::computeHmacFromFile($filePath, CHash::MD5, $key)->equals("120a17985a1e97bf8f0e38a52fb9fe79"));
     $this->assertTrue(CHash::computeHmacFromFile($filePath, CHash::SHA256, $key)->equals("e98139c39d76eb80d8db982552b44b251b94f312987f91ee72d12ef673caa813"));
     $this->assertTrue(CHash::computeHmacFromFile($filePath, CHash::SHA512, $key)->equals("451b681c334a8a24fe5baf00880443c7898d1c523db1d83bed03b2a46a960aec" . "a5bce23efba258225f5606fdb2c93a4b99d84b4bfd09f119a0971a2dff61db1e"));
     $this->assertTrue(CHash::computeHmacFromFile($filePath, CHash::WHIRLPOOL, $key)->equals("03047f3652094b2749b42a4cf4698030f08f0c52cda87a2a124134844411a54a" . "a4e80e02357a42df483b79ad0380dfd7188e00ac87396e59f17a09bf7ab4f834"));
     $this->assertTrue(CHash::computeHmacFromFile($filePath, CHash::CRC32, $key)->equals("d6132f08"));
     $this->assertTrue(CHash::computeHmacFromFile($filePath, CHash::HAVAL256_4, $key)->equals("45168e6656e7dfd2be8acde7b4520f7d95d5ba05a90a30aa028876e9e20fdc08"));
     CFile::delete($filePath);
 }