Encryption
Encryption has long been used by militaries and governments to facilitate secret communication. It is now commonly used in protecting information within many kinds of civilian systems. For example, the Computer Security Institute reported that in 2007, 71% of companies surveyed utilized encryption for some of their data in transit, and 53% utilized encryption for some of their data in storage. Encryption can be used to protect data "at rest", such as information stored on computers and storage devices (e.g. USB flash drives). In recent years, there have been numerous reports of confidential data, such as customers' personal records, being exposed through loss or theft of laptops or backup drives; encrypting such files at rest helps protect them if physical security measures fail. Digital rights management systems, which prevent unauthorized use or reproduction of copyrighted material and protect software against reverse engineering (see also copy protection), is another somewhat different example of using encryption on data at rest.
Affine cipher
In the affine cipher the letters of an alphabet of size are first mapped to the integers in the range . It then uses modular arithmetic to transform the integer that each plaintext letter corresponds to into another integer that correspond to a ciphertext letter.
The encryption function for a single letter is 
where modulus is the size of the alphabet and and are the key of the cipher. The value must be chosen such that and are coprime. The decryption function is 
where is the modular multiplicative inverse of modulo . I.e., it satisfies the equation 
The multiplicative inverse of only exists if and are coprime. Hence without the restriction on , decryption might not be possible.
It can be shown as follows that decryption function is the inverse of the encryption function,