quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

hello.c (857B)


      1 /*
      2  *  Classic "Hello, world" demonstration program
      3  *
      4  *  Copyright The Mbed TLS Contributors
      5  *  SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
      6  */
      7 
      8 #include "mbedtls/build_info.h"
      9 
     10 #include "mbedtls/platform.h"
     11 
     12 #if defined(MBEDTLS_MD5_C)
     13 #include "mbedtls/md5.h"
     14 #endif
     15 
     16 #if !defined(MBEDTLS_MD5_C)
     17 int main(void)
     18 {
     19     mbedtls_printf("MBEDTLS_MD5_C not defined.\n");
     20     mbedtls_exit(0);
     21 }
     22 #else
     23 
     24 
     25 int main(void)
     26 {
     27     int i, ret;
     28     unsigned char digest[16];
     29     char str[] = "Hello, world!";
     30 
     31     mbedtls_printf("\n  MD5('%s') = ", str);
     32 
     33     if ((ret = mbedtls_md5((unsigned char *) str, 13, digest)) != 0) {
     34         mbedtls_exit(MBEDTLS_EXIT_FAILURE);
     35     }
     36 
     37     for (i = 0; i < 16; i++) {
     38         mbedtls_printf("%02x", digest[i]);
     39     }
     40 
     41     mbedtls_printf("\n\n");
     42 
     43     mbedtls_exit(MBEDTLS_EXIT_SUCCESS);
     44 }
     45 #endif /* MBEDTLS_MD5_C */