my_md5.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #ifndef MY_MD5_INCLUDED
  2. #define MY_MD5_INCLUDED
  3. /* Copyright (c) 2000, 2012, Oracle and/or its affiliates.
  4. Copyright (c) 2013 Monty Program Ab
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; version 2 of the License.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
  15. #include "m_string.h"
  16. #define MD5_HASH_SIZE 16 /* Hash size in bytes */
  17. /*
  18. Wrapper function for MD5 implementation.
  19. */
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. #define compute_md5_hash(A,B,C) my_md5(A,B,C)
  24. /*
  25. Convert an array of bytes to a hexadecimal representation.
  26. Used to generate a hexadecimal representation of a message digest.
  27. */
  28. static inline void array_to_hex(char *to, const unsigned char *str, uint len)
  29. {
  30. const unsigned char *str_end= str + len;
  31. for (; str != str_end; ++str)
  32. {
  33. *to++= _dig_vec_lower[((uchar) *str) >> 4];
  34. *to++= _dig_vec_lower[((uchar) *str) & 0x0F];
  35. }
  36. }
  37. #ifdef __cplusplus
  38. }
  39. #endif
  40. #endif /* MY_MD5_INCLUDED */