Hi all,
I have small issue that i cant figure out why.
uint8_t nonce[16] = "1234567890123456";
String cipherText = String();
for (int i = 0; i < 17; i++) {
char str[3];
sprintf(str, "%02X", nonce);
cipherText = cipherText+String(str);
}
System.println(cipherText);
result is: "31323334353637383930313233343537"
when i use hex converter online the de hex result is "1234567890123457"
hex converter online: https://string-functions.com/hex-string.aspx
The last value will always increase + 1
Anyone can help whats wrong with this codes?
Converting to HEX and deHex increase end String value + 1
Re: Converting to HEX and deHex increase end String value + 1
unsigned char nonce[16] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
ESP_LOGE(TAG, "[LOGGER]: nonce. %x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x", nonce[0], nonce[1], nonce[2], nonce[3], nonce[4], nonce[5], nonce[6], nonce[7], nonce[8], nonce[9], nonce[10], nonce[11], nonce[12], nonce[13], nonce[14], nonce[15]);
[LOGGER]: nonce. 1111111111111112
ESP_LOGE(TAG, "[LOGGER]: nonce. %x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x", nonce[0], nonce[1], nonce[2], nonce[3], nonce[4], nonce[5], nonce[6], nonce[7], nonce[8], nonce[9], nonce[10], nonce[11], nonce[12], nonce[13], nonce[14], nonce[15]);
[LOGGER]: nonce. 1111111111111112
Re: Converting to HEX and deHex increase end String value + 1
tsctrl wrote: ↑Thu Dec 30, 2021 3:02 pmHi all,
I have small issue that i cant figure out why.
uint8_t nonce[16] = "1234567890123456";
String cipherText = String();
for (int i = 0; i < 17; i++) {
char str[3];
sprintf(str, "%02X", nonce);
cipherText = cipherText+String(str);
}
System.println(cipherText);
result is: "31323334353637383930313233343537"
when i use hex converter online the de hex result is "1234567890123457"
hex converter online: https://string-functions.com/hex-string.aspx
The last value will always increase + 1
Anyone can help whats wrong with this codes?
But you know you are trying to read beyond nonce array? What i mean you are reading 17 elements from array size of 16.
Re: Converting to HEX and deHex increase end String value + 1
yup, tested with 16 with the same issue.
Re: Converting to HEX and deHex increase end String value + 1
i have use base64 also with the same issue. and also use other loop approach.
thanks!
thanks!
Re: Converting to HEX and deHex increase end String value + 1
hi @chegewara, yes you correct. the issue is the iv need to be copy as on your other reply on other post here
viewtopic.php?f=2&t=25269
thanks you so much and happy new year!
viewtopic.php?f=2&t=25269
thanks you so much and happy new year!
Who is online
Users browsing this forum: Bing [Bot] and 84 guests