First time posting.
I am trying to write a simple program that takes a file path and a hash type from standard input, and outputs the corresponding hash using certutil. Later I would like to compare the hash to one that the user enters, and output a pass or fail statement.
#include <iostream>
#include <string>
using namespace std;
int main() {
string hash_type;
string path_to_file;
cout<<"Enter full file path to hash: "<<endl;
cin>>path_to_file;
cout<<"
Filepath is: "<<path_to_file;
cout<<"
Which hash to use? (e.g SHA256)"<<endl;
cin>>hash_type;
cout<<"
Hash type is: "<<hash_type<<endl;
I have tried with or without the cout;
cout<<system("certutil -hashfile path_to_file hash_type");
system("certutil -hashfile C:UsersmooseDesktopcurrent.cpp SHA256")
This will run perfectly fine, and I see the resultant hash. I just can't seem to use the strings from standard input. I suspect it could have something to do with the extra backslash needed in the filepath or another delimiter?
return 0;
}
I'm still learning about pointers, but I have also tried the following; system("certutil -hashfile *path_to_file *hash_type");
since I am getting the following error:
Certutil: -hashfile command FAILED: 0x80070002
Certutil: The system cannot find the file specified.
'hash_type' is not recognised as an internal or external command, operable program or batch file
I would appreciate any help. Thanks in advance.
question from:
https://stackoverflow.com/questions/65852814/running-certutil-hashfile-with-standard-inputs-for-filepath-and-hashtype-c 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…