In more detail
The signer hashes the message and transforms the hash with their private key; anyone can check the result with the matching public key (Public-key cryptography). Changing even one bit of the message breaks the signature. Signatures protect software updates, certificates, signed PDFs and DKIM email.