Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For super large ArrayBuffer, encryption will report RangeError: Invalid array length #497

Open
Jeggery opened this issue Aug 13, 2024 · 0 comments

Comments

@Jeggery
Copy link

Jeggery commented Aug 13, 2024

I have a file that is binary and I want to encrypt it. However, when converting from an ArrayBuffer to a wordArray, an error occurs.
export function arrayBufferToWordArray(ab: ArrayBuffer) { var i8a = new Uint8Array(ab); var a: number[] = []; for (var i = 0; i < i8a.length; i += 4) { var word = 0; for (var j = 0; j < 4 && i + j < i8a.length; j++) { word |= i8a[i + j] << (24 - j * 8); } a.push(word); // a.push((i8a[i] << 24) | (i8a[i + 1] << 16) | (i8a[i + 2] << 8) | i8a[i + 3]); } }
Array a will display Invalid array length

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant