Digital signatures use public key encryption to authenticate, provide integrity for, and help prevent repudiation of electronic messages and documents. They work by applying a hash function to create a digest of the message, encrypting the digest with the sender's private key, and attaching it to the message. The recipient decrypts the digest using the sender's public key and compares it to a newly generated digest of the received message. If they match, the signature is validated and the three aspects of security - authentication, integrity, and non-repudiation - are preserved. Signing a digest is more efficient for long messages than signing the full document.