Bg96 checksum for file after uploaded - c code

hello I’m trying to confirm that file uploaded is right via UART and AT+QFUPL the documentation FILE for bg 96 said:

is a 16 bit checksum based on bitwise XOR.
If the number of the characters is odd, set the last character as the high 8 bit, and the low 8 bit as 0,
and then use an XOR operator to calculate the checksum.

my c code are into gist with two wrong version of code:
(https://gist.github.com/stbnrivas/a210b252a9e6d72b8e43474297cef3ca)

any help in any language is welcome, thanks in advanced

this operation of checksum is done by module , normally customer does not need to care it ,just send AT

Sorry I’m not agree I need during the development.

My problem was into invisible characters of \r\n at some certifies I was sending without \n and print and check if checksum that calculated out the module directly from raw cert file and compare with module checksum do more easy find the problem

NOTE: using the QCOM also show the file size and checksum if you have usb to quectel available in your circuit

Thanks

In any case there is my link to my implementation in c I don’t remember which of two functions are the right