Open Sagaryalioe opened 6 years ago
Do you solve the issue?
You can try the following code:
let sha1Hash = CryptoJS.algo.SHA1.create();
let md5Hash = CryptoJS.algo.MD5.create();
const contentBuffer = fs.readFileSync('./test.png');
const contentWordArray = CryptoJS.lib.WordArray.create(new Uint8Array(contentBuffer));
sha1Hash = sha1Hash.update(contentWordArray);
md5Hash = md5Hash.update(contentWordArray);
console.log(md5Hash.finalize().toString(CryptoJS.enc.Hex));
console.log(sha1Hash.finalize().toString(CryptoJS.enc.Hex));
How do you encrypt a whole file? Like zip, epub files and write the encrypted data to a file in storage. Thankyou.