Google is your friend.
Look at gpg/pgp for example uses.
There are several kinds of electronic signatures. But the most common type uses RSA. This is a crude overview. From wikipedia:
A digital signature scheme typically consists of three algorithms:
* A key generation algorithm that selects a private key uniformly at random from a set of possible private keys. The algorithm outputs the private key and a corresponding public key.
* A signing algorithm which, given a message and a private key, produces a signature.
* A signature verifying algorithm which given a message, public key and a signature, either accepts or rejects.