Source: https://web.eecs.utk.edu/~mschucha/crypto/doc/ex1.pdf