Skip to content

Commit e4b973d

Browse files
Andres Amaya GarciaAndres Amaya Garcia
authored andcommitted
Hashing: Convert line endings from \r\n to \n
1 parent 7b0cafc commit e4b973d

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

hashing/main.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ static void print_hex(const char *title, const unsigned char buf[], size_t len)
4040
for (size_t i = 0; i < len; i++)
4141
mbedtls_printf("%02x", buf[i]);
4242

43-
mbedtls_printf("\r\n");
43+
mbedtls_printf("\n");
4444
}
4545

4646
static const char hello_str[] = "Hello, world!";
@@ -49,7 +49,7 @@ static const size_t hello_len = strlen(hello_str);
4949

5050
static int example(void)
5151
{
52-
mbedtls_printf("\r\n\r\n");
52+
mbedtls_printf("\n\n");
5353

5454
/*
5555
* Method 1: use all-in-one function of a specific SHA-xxx module
@@ -93,15 +93,15 @@ static int example(void)
9393

9494
if (md_info3 == NULL)
9595
{
96-
mbedtls_printf("SHA256 not available\r\n");
96+
mbedtls_printf("SHA256 not available\n");
9797
return 1;
9898
}
9999

100100
int ret3 = mbedtls_md(md_info3, hello_buffer, hello_len, output3);
101101

102102
if (ret3 != 0)
103103
{
104-
mbedtls_printf("md() returned -0x%04X\r\n", -ret3);
104+
mbedtls_printf("md() returned -0x%04X\n", -ret3);
105105
return 1;
106106
}
107107

@@ -117,7 +117,7 @@ static int example(void)
117117

118118
if (md_info4 == NULL)
119119
{
120-
mbedtls_printf("SHA256 not available\r\n");
120+
mbedtls_printf("SHA256 not available\n");
121121
return 1;
122122
}
123123

@@ -128,7 +128,7 @@ static int example(void)
128128
int ret4 = mbedtls_md_init_ctx(&ctx4, md_info4);
129129
if (ret4 != 0)
130130
{
131-
mbedtls_printf("md_init_ctx() returned -0x%04X\r\n", -ret4);
131+
mbedtls_printf("md_init_ctx() returned -0x%04X\n", -ret4);
132132
return 1;
133133
}
134134

@@ -146,14 +146,14 @@ static int example(void)
146146
mbedtls_md_free(&ctx4);
147147

148148

149-
mbedtls_printf("\r\nDONE\r\n");
149+
mbedtls_printf("\nDONE\n");
150150

151151
return 0;
152152
}
153153

154154
int main() {
155155
int ret = example();
156156
if (ret != 0) {
157-
mbedtls_printf("Example failed with error %d\r\n", ret);
157+
mbedtls_printf("Example failed with error %d\n", ret);
158158
}
159159
}

hashing/mbed_app.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"target_overrides": {
3+
"*": {
4+
"platform.stdio-convert-newlines": true
5+
}
6+
}
7+
}

0 commit comments

Comments
 (0)