简体   繁体   English

增加crypto-js加密中的文件大小限制

[英]Increase the file size limitation in crypto-js encryption

I have come across a tutorial that shows you how to encrypt files in the client-side encryption model using the crypto-js library and the problem is that the tutorial has created a limitation for the file size to be 1MB and I want to increase the limitation of this.我遇到了一个教程,向您展示了如何使用 crypto-js 库在客户端加密模型中加密文件,问题是该教程将文件大小限制为 1MB,我想增加对此的限制。

My question is how can I achieve that?我的问题是我怎样才能做到这一点?

The tutorial: https://tutorialzine.com/2013/11/javascript-file-encrypter教程: https : //tutorialzine.com/2013/11/javascript-file-encrypter

Change the value in the conditional check below (this snippet is from the tutorial link you referenced) to something larger.将下面条件检查中的值(此片段来自您引用的教程链接)更改为更大的值。

1024 bytes is 1KB, multiplied by 1024 is 1 MB. 1024 字节为 1KB,乘以 1024 为 1 MB。 As an example, if you want the limit to be 5 MB, use 5*1024*1024 .例如,如果您希望限制为 5 MB,请使用5*1024*1024

if(file.size > 1024*1024){
  alert('Please choose files smaller than 1mb, otherwise you may crash your browser. \nThis is a known issue. See the tutorial.');
  return;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM