But I the downloaded pdf file is corrupted or empty and I am not able to open it at all.
When I console log the encryptedData.toString() I get something like this: U2FsdGVkX19UTadvO67I4hsuI+deTOVQKCelKM1B5rvRtCL67GnYrP09... and the string just goes on which seems like it's correct.
When I console log decryptedData i get something like this (I had to upload the photo because when pasting it as text it would not format correctly):
But when downloaded the file won't open. When it comes to size the decrypted file that I download is larger then the one I upload. So I am not sure if it's encryption or decryption that corrupts it, or something else.
When I try with a plain .txt and log the encryptedData.toString() I get again a long string of random characters and when I log decryptedData then it logs the content of the .txt file, but when I download it as text/plain it's just empty. So plan txt doesn't work either.
I am trying to find the way how to encrypt and decrypt pdf file. I have a encrypt function:
And then I want to decrypt it and download it
But I the downloaded pdf file is corrupted or empty and I am not able to open it at all.
When I console log the
encryptedData.toString()
I get something like this:U2FsdGVkX19UTadvO67I4hsuI+deTOVQKCelKM1B5rvRtCL67GnYrP09...
and the string just goes on which seems like it's correct.When I console log decryptedData i get something like this (I had to upload the photo because when pasting it as text it would not format correctly):
But when downloaded the file won't open. When it comes to size the decrypted file that I download is larger then the one I upload. So I am not sure if it's encryption or decryption that corrupts it, or something else.
When I try with a plain .txt and log the encryptedData.toString() I get again a long string of random characters and when I log decryptedData then it logs the content of the .txt file, but when I download it as text/plain it's just empty. So plan txt doesn't work either.