Open rupamking1 opened 3 years ago
Can you clarify, please? If the file is text formatted (ex. utf8) you can get a string of the file with fs.readFileSync, and then pass that into your preferred cipher (ex. AES).
For example (assuming test.txt is utf-8 encoded):
const passphrase = 'secret key';
const string = fs.readFileSync('test.txt', {encoding: 'utf-8'});
const encryptedString = cryptoJS.AES.encrypt(string, passphrase);
You could then decrypt it like this:
let decryptedString = cryptoJS.AES.decrypt(encryptedString, passphrase).toString(cryptoJS.enc.Utf8);
How to encrypt decrypt file pls write documentation encrypt decrypt file