CryptoJS AES增加文件大小 [英] CryptoJS AES Increase File Size

查看:469
本文介绍了CryptoJS AES增加文件大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谢谢您的帮助。

我对sjcl库或cryptojs aes库有问题。
每次我用aes加密文件时,文件大小为*2。
例如:当我上载4mb文件时,服务器上有8mb文件。

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.

我在块上分割了文件,字节大小可以除以16。

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

请帮助我

这是我加密文件的方式:

This is the way i encrypt the file:

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

这是一个示例数组,具有4mb文件中的块大小:

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

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

而FileKey是SHA-256哈希

And the FileKey is a SHA-256 Hash

推荐答案

您正在将密文输出( CipherParams 对象)转换为字符串。默认情况下,CryptoJS通过以十六进制表示结果来实现此目的,其中每个字节被编码为两个十六进制数字。您可以通过提供自定义格式策略来覆盖此行为。或者更好的是,不要将密文转换为字符串;

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.

这篇关于CryptoJS AES增加文件大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆