Digital signatures work by generating a unique hash of the message or document to be signed. This hash is then encrypted using the sender's private key, creating the digital signature. The recipient uses the sender's public key to decrypt the hash, confirming that it matches the original document and verifying the sender's identity.