/hphp/test/zend/good/ext/hash/tests/hmac-md5.php

http://github.com/facebook/hiphop-php · PHP · 13 lines · 10 code · 2 blank · 1 comment · 0 complexity · 67001b8c0777f447cfc8afaec9c77471 MD5 · raw file

  1. <?hh
  2. <<__EntryPoint>> function main(): void {
  3. /* Test Vectors from RFC 2104 */
  4. $ctx = hash_init('md5',HASH_HMAC,str_repeat(chr(0x0b), 16));
  5. hash_update($ctx, 'Hi There');
  6. echo hash_final($ctx) . "\n";
  7. $ctx = hash_init('md5',HASH_HMAC,'Jefe');
  8. hash_update($ctx, 'what do ya want for nothing?');
  9. echo hash_final($ctx) . "\n";
  10. echo hash_hmac('md5', str_repeat(chr(0xDD), 50), str_repeat(chr(0xAA), 16)) . "\n";
  11. }