Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.2 KiB

  1. package Digest::HMAC_MD5;
  2. $VERSION="1.00";
  3. use strict;
  4. use Digest::MD5 qw(md5);
  5. use Digest::HMAC qw(hmac);
  6. # OO interface
  7. use vars qw(@ISA);
  8. @ISA=qw(Digest::HMAC);
  9. sub new
  10. {
  11. my $class = shift;
  12. $class->SUPER::new($_[0], "Digest::MD5", 64);
  13. }
  14. # Functional interface
  15. require Exporter;
  16. *import = \&Exporter::import;
  17. use vars qw(@EXPORT_OK);
  18. @EXPORT_OK=qw(hmac_md5 hmac_md5_hex);
  19. sub hmac_md5
  20. {
  21. hmac($_[0], $_[1], \&md5, 64);
  22. }
  23. sub hmac_md5_hex
  24. {
  25. unpack("H*", &hmac_md5)
  26. }
  27. 1;
  28. __END__
  29. =head1 NAME
  30. Digest::HMAC_MD5 - Keyed-Hashing for Message Authentication
  31. =head1 SYNOPSIS
  32. # Functional style
  33. use Digest::HMAC_MD5 qw(hmac_md5 hmac_md5_hex);
  34. $digest = hmac_md5($data, $key);
  35. print hmac_md5_hex($data, $key);
  36. # OO style
  37. use Digest::HMAC_MD5;
  38. $hmac = Digest::HMAC_MD5->new($key);
  39. $hmac->add($data);
  40. $hmac->addfile(*FILE);
  41. $digest = $hmac->digest;
  42. $digest = $hmac->hexdigest;
  43. $digest = $hmac->b64digest;
  44. =head1 DESCRIPTION
  45. This module provide HMAC-MD5 hashing.
  46. =head1 SEE ALSO
  47. L<Digest::HMAC>, L<Digest::MD5>, L<Digest::HMAC_SHA1>
  48. =head1 AUTHOR
  49. Gisle Aas <[email protected]>
  50. =cut