/include/password-methods/class_password-methods-md5.inc

https://github.com/bollwarm/fusiondirectory · PHP · 76 lines · 24 code · 7 blank · 45 comment · 2 complexity · b08b120a9cbf1224fb1e8232364a9733 MD5 · raw file

  1. <?php
  2. /*
  3. This code is part of FusionDirectory (http://www.fusiondirectory.org/)
  4. Copyright (C) 2003-2010 Cajus Pollmeier
  5. Copyright (C) 2011-2013 FusionDirectory
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2 of the License, or
  9. (at your option) any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
  17. */
  18. /*!
  19. * \file class_password-methods-md5.inc
  20. * Source code for class passwordMethodMd5
  21. */
  22. /*!
  23. * \brief This class contains all the functions for md5 password methods
  24. * \see passwordMethod
  25. */
  26. class passwordMethodMd5 extends passwordMethod
  27. {
  28. /*!
  29. * \brief passwordMethodMd5 Constructor
  30. *
  31. * \param string $config
  32. */
  33. function __construct($config)
  34. {
  35. }
  36. /*!
  37. * \brief Is available
  38. *
  39. * \return TRUE if is avaibable, otherwise return false
  40. */
  41. function is_available()
  42. {
  43. if (function_exists('md5')) {
  44. return TRUE;
  45. } else {
  46. return FALSE;
  47. }
  48. }
  49. /*!
  50. * \brief Generate template hash
  51. *
  52. * \param string $pwd Password
  53. */
  54. function generate_hash($pwd)
  55. {
  56. return "{MD5}".base64_encode( pack('H*', md5($pwd)));
  57. }
  58. /*!
  59. * \brief Get the hash name
  60. */
  61. static function get_hash_name()
  62. {
  63. return "md5";
  64. }
  65. }
  66. ?>