Question: Please help with coding this in C++ ---------------------------------------------------- Generate and verify digital signatures using a SHA-256 hash. -Sign a given file 1. Generate a SHA-256

Please help with coding this in C++

----------------------------------------------------

Generate and verify digital signatures using a SHA-256 hash.

-Sign a given file

1. Generate a SHA-256 hash of the content of the file to be signed (e.g., "file.txt", file.exe);

2. Sign/"decrypt" this hash value using the private key stored in d_n.txt;

3. Save the signature to "file.txt.signature" (in practice, the original content and the signature are saved in one document);

4. Verify the signed file

5. Generate a SHA-256 hash of the content of the file to be signed (e.g., "file.txt", file.exe);

6. Obtain the signature from the signature file (e.g. "file.txt.signature");

7. "encrypt" saved hash value (signature) using the public key stored in e_n.txt;

8. Compare the SHA-256 hash value and the encrypted signature;

9. Report whether the document is authentic or modified.

10. Signing and verification work for binary files such as .exe, .doc, .jpg. (Note: small modification needed for sha-256.cpp file).

--------------------------------------------------------------------------------

SHA-256 algorithm generates an almost-unique, fixed size 256-bit (32-byte) hash: http://www.zedwood.com/article/cpp-sha256-function.

run it using:

sign.exe s file.txt to sign and sign.exe v file.txt.signed signature_file to verify.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!