# Is there any chance of failure in Cryptography

With my limited knowledge of cryptography and its correct terms, functions (md5, base64, sha, aes or whatever) turn an input into encrypted output. For example, if the following input turns into following output:

input | output
______________
A     |  XX
B     |  YY
AB    |  ZZ


my question is: do such cryptography functions involve proven mechanism to avoid the failure of "repeated-output"? I mean, is there any chance, if inputing AB provides ZZ output, can there be any other input (like %) that might have the same output ZZ ?

What is the mechanism to ensure there doesn't exist two different input that provide the same output?

As for the "whatever": cryptography consists of many algorithms, and the outcome depends on the algorithm. If the output is supposed to be indistinguishable from random and there are $$n$$ different outputs then you'd expect a $$1 \over n$$ chance of that a value is equal to a preset earlier output value. However, due to the birthday bound you'd expect to compare only $$\sqrt n$$ values against each other before you find a collision with a 50% chance of success.
In the case of MD5 with an output size of 128 bits, so $$n = 2^{128}$$- you'd expect a collision in about $$\sqrt {2^{128}} = 2^{64}$$ compares. That means a collisions resistance of 64 bits in other words. However, because it is broken attackers can create collisions much more easily. Generally cryptographers aim to have a security margin of 128 bits, which means that MD5 is considered insecure with regards to collision resistance even if it was not broken.