1

Please help ,

Problem : I am reading file content using HTML5 FileReaderAPI -> ReadAsArrayBuffer. I am storing that buffer in a variable. Now I want to compute CRC of that ArrayBuffer ?

How shall I proceed. No clues. All operations are to be performed on browser side.

Let me tell you I am using arayBuffer because, that file contains Binary Data. So, I can not use anything other than ArrayBuffer. If we can use anything else than please tell that also.

1 Answer 1

2

You can make an slight modification of this solution to work on arrays instead of on strings. Basically change the str.charCodeAt(i) to str[i].

Use a data view on your array buffer to access the elements in the array:

var dataview = new DataView(buffer);

Then use this:

dataview.getInt8(i);
Sign up to request clarification or add additional context in comments.

12 Comments

JotaBe: I know how how to compute CRC. As you also know that CRC function takes string str as input. But I have arrayBuffer as my input to this function. This will not work for mu sure.
That's why I'm saying that you have to slightly modify it. Try. if you cannot, show why.
I've added more clues fro your modification.
See, first of all I dont have access to data of ArrayBuffer. So how shall I extract info.
I dont wanna to convert to Int8 , Actually , if I convert it to int8 then the orignal length of the array buffer and the converted int8 length or size will mismatch. As, i am using one parameter that keeps record of the orignal size of arraybuffer. And If i convert it to int8 the size will get increased. Please suggest.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.