Source: https://maths.ac-noumea.nc/IMG/pdf/crypto1.pdf