Skip to content

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

@Jeggery

Description

@Jeggery

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions