Strings can be compared against each other typically by examining individual characters from each until a mis-match is discovered.
Distinct matching algorithms can compare a shorter string to a longer string expecting to find the sorter at the beginning, then end, or anywhere within the longer string.
Long strings and even whole files can be compared by computing a representative sum that is strongly associated with the character contents. A mismatch is then conclusive while a match of sums indicate further validation can confirm that the match is not an accident.
The representative sums are sometimes called hashes and sometimes named for published summing algorithms such as CRC, MD5 or SHA1.
A String and its sum can be communicated together and then checked for equivalence on the receiving end in order to detect or sometimes even correct small errors.