Cryptographic hash function

Many authentication algorithms use one-way hash functions. These functions encrypt variable size blocks of data into a fixed size buffer, which cannot be used to obtain the original plaintext (hence one-way).

By including some hashed token at the end of an encrypted message, the receiver can verify that the hash of this token matches what they expecte from the sender, thus ensuring authenticity.

If the token is in some way related to the state of the message, this approach might also infer that the message's integrity is intact.