Skip to content

Decryption of non-string content fails due to utf8 stringification #2

@elyobo

Description

@elyobo

When decrypting the content is assumed to be a UTF8 string, but this isn't always the case. I have some content that's encrypted bytes, and the conversion of the buffer to a UTF8 string causes it to be filled up with 239, 191, 189 sequences, the � replacement character.

      const decrypted = aesDecrypt(cipherText, encryptionKey, iv);
      return decrypted.toString('utf-8');

Just returning a buffer would be more flexible; similarly it would be more flexible to allow encryption of more than just strings, which the types here, here and here don't permit, but cipher.update is much more permissive in what it allows.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions