hello.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * Classic "Hello, world" demonstration program
  3. *
  4. * Copyright (C) 2006-2010, Brainspark B.V.
  5. *
  6. * This file is part of PolarSSL (http://www.polarssl.org)
  7. * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
  8. *
  9. * All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License along
  22. * with this program; if not, write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  24. */
  25. #ifndef _CRT_SECURE_NO_DEPRECATE
  26. #define _CRT_SECURE_NO_DEPRECATE 1
  27. #endif
  28. #ifdef PRINTF_STDLIB
  29. #include <stdio.h>
  30. #endif
  31. #ifdef PRINTF_CUSTOM
  32. #include "tinystdio.h"
  33. #endif
  34. #include "polarssl/config.h"
  35. #include "polarssl/md5.h"
  36. #if !defined(POLARSSL_MD5_C)
  37. int main( void )
  38. {
  39. printf("POLARSSL_MD5_C not defined.\n");
  40. return( 0 );
  41. }
  42. #else
  43. int main( void )
  44. {
  45. int i;
  46. unsigned char digest[16];
  47. char str[] = "Hello, world!";
  48. printf( "\n MD5('%s') = ", str );
  49. md5( (unsigned char *) str, 13, digest );
  50. for( i = 0; i < 16; i++ )
  51. printf( "%02x", digest[i] );
  52. printf( "\n\n" );
  53. #ifdef WIN32
  54. printf( " Press Enter to exit this program.\n" );
  55. fflush( stdout ); getchar();
  56. #endif
  57. return( 0 );
  58. }
  59. #endif /* POLARSSL_MD5_C */