CryptoJS AES Increase File Size

你。 提交于 2019-12-24 13:26:32

问题


Thank you for your help.

I have a problem with sjcl library or cryptojs aes library. Everytime i encrypt my file with aes the file size is * 2. For example: When i upload a 4mb file then there is a 8mb file on my server.

I split the file on block which bytesize can be divided by 16.

Please help me

This is the way i encrypt the file:

var l_EncryptetData = CryptoJS.AES.encrypt(p_ChunkData, p_FileKey).toString();

And this is a example array with block sizes from the 4mb file:

0: 1572864
1: 1572864
2: 867005
length: 3

And the FileKey is a SHA-256 Hash


回答1:


You are converting the cipher output (a CipherParams object) to a character string. By default, CryptoJS does this by representing the result in hexadecimal, where each byte is encoded as two hex digits. You can override this behavior by providing a custom format strategy. Or better yet, don't convert the cipher text to a character string; keep it as binary data.

Please warn users of your application that it is not secure.



来源:https://stackoverflow.com/questions/31299236/cryptojs-aes-increase-file-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!