1 /*
2  *  Classic "Hello, world" demonstration program
3  *
4  *  Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
5  *  SPDX-License-Identifier: Apache-2.0
6  *
7  *  Licensed under the Apache License, Version 2.0 (the "License"); you may
8  *  not use this file except in compliance with the License.
9  *  You may obtain a copy of the License at
10  *
11  *  http://www.apache.org/licenses/LICENSE-2.0
12  *
13  *  Unless required by applicable law or agreed to in writing, software
14  *  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15  *  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  *  See the License for the specific language governing permissions and
17  *  limitations under the License.
18  *
19  *  This file is part of mbed TLS (https://tls.mbed.org)
20  */
21 
22 #if !defined(MBEDTLS_CONFIG_FILE)
23 #include "mbedtls/config.h"
24 #else
25 #include MBEDTLS_CONFIG_FILE
26 #endif
27 
28 #if defined(MBEDTLS_PLATFORM_C)
29 #include "mbedtls/platform.h"
30 #else
31 #include <stdio.h>
32 #define mbedtls_printf     printf
33 #endif
34 
35 #if defined(MBEDTLS_MD5_C)
36 #include "mbedtls/md5.h"
37 #endif
38 
39 #if !defined(MBEDTLS_MD5_C)
main(void)40 int main( void )
41 {
42     mbedtls_printf("MBEDTLS_MD5_C not defined.\n");
43     return( 0 );
44 }
45 #else
main(void)46 int main( void )
47 {
48     int i;
49     unsigned char digest[16];
50     char str[] = "Hello, world!";
51 
52     mbedtls_printf( "\n  MD5('%s') = ", str );
53 
54     mbedtls_md5( (unsigned char *) str, 13, digest );
55 
56     for( i = 0; i < 16; i++ )
57         mbedtls_printf( "%02x", digest[i] );
58 
59     mbedtls_printf( "\n\n" );
60 
61 #if defined(_WIN32)
62     mbedtls_printf( "  Press Enter to exit this program.\n" );
63     fflush( stdout ); getchar();
64 #endif
65 
66     return( 0 );
67 }
68 #endif /* MBEDTLS_MD5_C */
69