You always need some shared data that was not tampered with in order to obtain integrity or confidentiality. This shared data is usually a shared secret key or the sender's public key.
With a shared secret key you'd use an HMAC, that is hmac(message, key)
.
If the receiver has the senders public key then the sender can use their private key to sign the message (many possible methods, DSA, RSA, etc) and the receiver can use the public key to determine if the message originated from the sender.