I know the definitions of both but can't specifically tell how they are different and if one is better than the other. Please help.
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
They are used in completely different contexts. In public key encryption there is the notion of signature that protects sender authenticity. The secret key is used as the signing key and everybody can verify its correctness. On the other hand in symmetric encryption there is the notion of MAC that protects the integrity of the message with an agreed MAC key between the sender and the receiver.
The main functional difference is that anyone able to verify a Message Authentication Code is also able to forge one, because the same key is used for both tasks; whereas someone with the public key can verify a digital signature, but can't forge one.
Contrary to a MAC, digital signature is thus usable in contexts where the verifier is not trusted, which is of tremendous practical value. There's a price to pay for that: a digital signature is significantly larger, and slower to generate and/or verify, than a MAC is.