Skip to content

Web crypto stringToArrayBuffer sample implementation seems off #231

Closed
@priyajeet

Description

@priyajeet

Looks like these lines do nothing since buf is returned. Should return bufView? Which may also fix issues related to nodejs/node#46067 (see upstream issues linked to this issue and solutions) which was causing errors like below thrown for people using that implementation.

'importkey' on 'subtlecrypto': 2nd argument is not instance of arraybuffer, buffer, typedarray, or dataview.

Example code on this page also needs fixing as it copy/pastes the stringToArrayBuffer implementation.
https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey

Also see, where bufView is returned.
https://stackoverflow.com/questions/34814480/how-to-load-a-public-key-in-pem-format-for-encryption

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageTriage needed by staff and/or partners. Automatically applied when an issue is opened.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions