A digital signature is a stamp on the data, which is unique and very hard to forge. A digital signature has 2 steps and creates 2 things from the security perspective.
STEP 1: To sign a document seems hashing software will break the data into just a few lines by the process called 'hashing'. These few lines are named message digest. It is not possible to modify the message digest back to its original data. Same as what we used above in cryptography hashes. This establishes whether the message has been changed between the time it was digitally signed and sent and time it was gets by the recipient.
STEP 2: Computing the digest can identify the integrity of the message but does not stop from someone intercepting it or verifying the identity of the user. This is where encryption comes into picture. Signing the code with the private key will be useful for giving that the message must have come from the user who claims to have signed it. The second step in making a digital signature includes encrypting the digest code prepared in STEP 1 with the sender's private key