A keyed hash function, also known as a message authentication code (MAC), is a cryptographic algorithm that produces a fixed-size output (hash) using both an input message and a secret key, ensuring data integrity and authenticity. It prevents tampering by allowing only those who possess the secret key to generate or verify the hash, making it crucial for secure communications and data verification.