Writing a method for identifying tampered files from the list of files

The fileCheck method identifies the list of tampered files from the  extFile file array. To do this, it calls the backend hashreadfile service:

  1. We start by locally capturing the list of files in the extFile variable. As you might remember, this is the list of files present during the initial hashing and the verification check. We want to identify which files among these may have been tampered with:
filecheck = () =>{

const files = this.state.extFile;
const DirPath = this.state.fields.DirPath;
let app = this;
  1. Next, we call the hashreadfile service in our backend node server. As you might remember, the input parameters are DirPath (directory path) and files (the list of files present in the directory):
 fetch('http://localhost:3602/api/hashreadfile', {
method: 'POST',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
},

body: JSON.stringify({
DirPath: DirPath,
files: files
})
}).then(function(response,error) {
  1. Upon a successful response, we parse the response.json object to fetch the data returned by the backend:
if(response)
{
console.log(response);
return response.json();
}
else
{
console.log(error);
}
}).then(function(data){
  1. The backend hashreadfile service returns the file array to us with the status of the files. This list is stored in the state variable verfile. At the same time, the vstatus flag is set to true to notify the app to render the FolberBlockChkStatus component with the list of tampered files:
app.setState({
verfile : data.res,
vstatus: true
})
});
}

This ends the fileCheck method for our App.js file .This also concludes the development of our app. Now let's run the components together to see how the app looks and functions.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.90.131