Since you brought up cryptography, one of the cool things good cryptographic algorithms do is, they make it nigh impossible to guess the exact algorithm (i.e. function plus key) that was used to encrypt something even if you have access to the input and output. Even if you have a small number of samples (i.e. a few billion) of inputs and matching outputs, you will not be able to predict the output that's generated by a new input.
In other words, what you want to do can't be done, unless you feed the program all possible inputs and outputs. You need to know more about the algorithm than just the inputs and outputs.
EDIT: There exist algorithms like neural networks - and a few others - which can be "trained" with a given set of inputs and outputs. For example, a neural network can be trained to tag pictures of birds in a set of random pictures. These sound like the simple and perfect solution, but the world is not that easy. Before training a neural network, it must be structured to match the problem it needs to solve, and in this case that requires additional information about what the algorithm it mimics does, otherwise training the network will fail.