This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12090|Reply: 3

crypto-js calculates the sha256 value of the file

[Copy link]
Posted on 3/20/2019 11:16:46 AM | | |
1. To calculate the sha256 or md5 value of a file in the browser, the basic idea is to use the HTML5 FileReader interface to read the file to memory (readAsArrayBuffer), then get the binary content of the file, and then get the shaa256 or md5 value of the file.

2. The ArrayBuffer is a piece of memory, and the ArrayBuffer object is used to represent a generic, fixed-length binary data buffer.

3. CryptoJS (crypto.js) provides a wide variety of cryptographic algorithms for JavaScript. The algorithms currently supported include: MD5 SHA-1 SHA-256 AES Rabbit MARC4 HMAC HMAC-MD5 HMAC-SHA1...

First read the file from input type=file and then calculate the sha256 value using the following code.






Previous:MySQL enables generic query logs and slow query logs
Next:crypto-js is encrypted using MD5
 Landlord| Posted on 8/14/2023 5:00:12 PM |
crypto-js is encrypted using MD5
https://www.itsvse.com/thread-7295-1-1.html
Posted on 12/21/2023 10:24:25 AM |
Prompt:Authors are banned or removed content is automatically blocked
 Landlord| Posted on 10/29/2024 2:33:46 PM |
Use FileReader.readAsArrayBuffer() to handle large files in the browser
https://www.itsvse.com/thread-7652-1-1.html
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com