index.js
/**
 * Write to disk encrypted file (.env.enc) from decrypted file (.env)
 * @param     {String}    passwd      the key used to encrypt the .env into .env.enc
 * @returns   {String}                writes the encrypted file to disk at same location where the encrypted file was found and returns its md5 checksum
 */
Write to disk encrypted file (.env.enc) from decrypted file (.env)
@param     {String}    passwd      the key used to encrypt the .env into .env.enc
@returns   {String}                writes the encrypted file to disk at same location where the encrypted file was found and returns its md5 checksum
Write to disk encrypted file ( . env . enc ) from decrypted file ( . env ) @param { String } passwd the key used to encrypt the . env into . env . enc @returns { String } writes the encrypted file to disk at same location where the encrypted file was found and returns its md5 checksum
function encrypt(passwd) {
  let cipher = crypto.createCipher(algor, passwd),
    decryptedFileLocation = findFileLocation(DECRYPTED_FILENAME),
    decryptedFileFullPath = decryptedFileLocation + DECRYPTED_FILENAME,
    encryptedFileFullPath = decryptedFileLocation + ENCRYPTED_FILENAME, 
    encBuff;
  if (!passwd) {
    throw new Error('encryption requires a password');
  }
  encBuff = Buffer.concat([cipher.update(readFile(decryptedFileFullPath)), cipher.final()]);
  writeFile(encryptedFileFullPath, encBuff);
  return md5FileSync(encryptedFileFullPath);
}
function encrypt ( passwd ) { let cipher = crypto . createCipher ( algor , passwd ) , decryptedFileLocation = findFileLocation ( DECRYPTED_FILENAME ) , decryptedFileFullPath = decryptedFileLocation + DECRYPTED_FILENAME , encryptedFileFullPath = decryptedFileLocation + ENCRYPTED_FILENAME , encBuff ; if ( ! passwd ) { throw new Error ( 'encryption requires a password' ) ; } encBuff = Buffer . concat ( [ cipher . update ( readFile ( decryptedFileFullPath ) ) , cipher . final ( ) ] ) ; writeFile ( encryptedFileFullPath , encBuff ) ; return md5FileSync ( encryptedFileFullPath ) ; }
Write to disk encrypted file (.env.enc) from decrypted file (.env)
 @param     {String}    passwd      the key used to encrypt the .env into .env.enc
 @returns   {String}                writes the encrypted file to disk at same location where the encrypted file was found and returns its md5 checksum
Write to disk encrypted file ( . env . enc ) from decrypted file ( . env ) @param { String } passwd the key used to encrypt the . env into . env . enc @returns { String } writes the encrypted file to disk at same location where the encrypted file was found and returns its md5 checksum
// we write encrypted file at same location as where we found decrypted file