Digitally signing a message

The purpose of signing a message is to let the recipient know the message came from the correct person. To sign a message, first generate the hash of the message and then use your private key to encrypt the hash. The encrypted hash is your signature.

The recipient will decrypt your signature to get the original hash you provided, then they will hash the message themselves and see if the hash they generated themselves from the message matches the decrypted value of the signature. If they match, the recipient knows that the signature is valid and it came from the correct sender.

Note that signing a message does not actually encrypt the message. You will still need to encrypt the message before sending it, if needed. ...

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.