This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

sha256_context_t datalen not right?

hi all, I use nRF52 SDK11 with ble_app_beacon example.And write some code in main().

uint8_t buf_data[32];
unsigned char c_data[] = {"abcd"};
//unsigned char c_data[] = {0x61, 0x62, 0x63, 0x64};

sha256_context_t ctx_data;
sha256_init(&ctx_data);
sha256_update(&ctx_data, c_data, strlen(c_data));
sha256_final(&ctx_data, buf_data);

After set breakpoint I can see sha256_context_t datalen = 4 , bitlen =32 and hash is right.

//unsigned char c_data[] = {"abcd"};
unsigned char c_data[] = {0x61, 0x62, 0x63, 0x64};

If I change code as above. then datalen =5 ,bitlen =40 ? I have try it use other example code is ok. What happened?

Parents Reply Children
No Data
Related