index.js
/**
 * Write to disk decrypted file (.env) from encrypted file (.env.enc)
 * Does not load the variables into process.env
 * @param     {String}    passwd      the key used to encrypt the .env into .env.enc we'll use now for decrpypting
 * @returns   {String}                writes the decrypted file to disk at same location where the decrypted file was found and returns its md5 checksum
 */
Write to disk decrypted file (.env) from encrypted file (.env.enc)
Does not load the variables into process.env
@param     {String}    passwd      the key used to encrypt the .env into .env.enc we'll use now for decrpypting
@returns   {String}                writes the decrypted file to disk at same location where the decrypted file was found and returns its md5 checksum
Write to disk decrypted file ( . env ) from encrypted file ( . env . enc ) Does not load the variables into process . env @param { String } passwd the key used to encrypt the . env into . env . enc we ' ll use now for decrpypting @returns { String } writes the decrypted file to disk at same location where the decrypted file was found and returns its md5 checksum
function decrypt(passwd) {
  let decipher = crypto.createDecipher(algor, passwd),
    encryptedFileLocation = findFileLocation(ENCRYPTED_FILENAME),
    encryptedFileFullPath = encryptedFileLocation + ENCRYPTED_FILENAME,
    decryptedFileFullPath = encryptedFileLocation + DECRYPTED_FILENAME, 
    decBuff;
  if (!passwd) {
    throw new Error('decryption requires a password');
  }
  decBuff = Buffer.concat([decipher.update(readFile(encryptedFileFullPath)), decipher.final()]);
  writeFile(decryptedFileFullPath, decBuff);
  return md5FileSync(decryptedFileFullPath);
}
function decrypt ( passwd ) { let decipher = crypto . createDecipher ( algor , passwd ) , encryptedFileLocation = findFileLocation ( ENCRYPTED_FILENAME ) , encryptedFileFullPath = encryptedFileLocation + ENCRYPTED_FILENAME , decryptedFileFullPath = encryptedFileLocation + DECRYPTED_FILENAME , decBuff ; if ( ! passwd ) { throw new Error ( 'decryption requires a password' ) ; } decBuff = Buffer . concat ( [ decipher . update ( readFile ( encryptedFileFullPath ) ) , decipher . final ( ) ] ) ; writeFile ( decryptedFileFullPath , decBuff ) ; return md5FileSync ( decryptedFileFullPath ) ; }
Write to disk decrypted file (.env) from encrypted file (.env.enc)
 Does not load the variables into process.env
 @param     {String}    passwd      the key used to encrypt the .env into .env.enc we'll use now for decrpypting
 @returns   {String}                writes the decrypted file to disk at same location where the decrypted file was found and returns its md5 checksum
Write to disk decrypted file ( . env ) from encrypted file ( . env . enc ) Does not load the variables into process . env @param { String } passwd the key used to encrypt the . env into . env . enc we ' ll use now for decrpypting @returns { String } writes the decrypted file to disk at same location where the decrypted file was found and returns its md5 checksum
// we write decrypted file at same location as where we found encrypted file