# Math

A core of cryptography is an understanding of mathematics. Algorithms will almost always include various math formulas to convert the plaintext data to ciphertext. Sometimes there may be simple usage of a series or array of numbers, as well as using any numbers in basic math operations, such as addition, subtraction, multiplication and division. Other times, it will be used in a conversion by various encoding standards, such as Base-16 for hexidecimal numbers and Base-2 for Binary numbers. Our number system is called the decimal system, or Base-10. In any base system, it defines the number of unique characters in each of the one's digit place.

Algorithms will also include non-mathematical steps in the entire process, to help with the final product. A simple substitution of alphabetic characters for others is non-mathematical if using one unique string against the typical alphabetic ordering. For instance, "abcd" could be using a substitution string of "zyxw", where "bad" becomes "yzw". This is just reversing the order of the alphabet. Using mathematics, we could compound the difficulty for someone to reason out how the cipher text is derived. Instead of using "zyxw", we might use "zxvt", which skips every other character in the alphabet while in reverse. This is the first use of mathematics within the encryption algorithm's process.

Modular arithmetic operations are very common in cryptography. These operations replace an integer by its remainder after division by the "modulus". Thus, 15 modulo 12 is 3, because dividing 15 by 12 gives a remainder of 3. The number 147 modulo 12 is also 3. When two integers have the same remainder modulo M, they are said to be "congruent modulo M". The relationship of congruence behaves very much like equality, and it is meaningful to speak of solving equations in modular arithmetic, where congruent integers are treated as equivalent. Several ciphers and key exchange algorithms depend on the difficulty of solving equations in modular arithmetic.

When it comes to deciphering messages, originally the frequency of occurrences of letters and/or words were used. This does not work well with the new encryption standards that exist today, but the underlying principle remains, that a sequence or pattern needs to be discerned to break the cipher. If a person has figured out the algorithm, they have an essential component in deducing the meaning of a ciphertext message.

Once a person has figured out the algorithm, if it is an algorithm designed with no knowledge of Auguste Kerckhoffs' principle -- including all "classical" ciphers, all ciphers designed before 1917, and most algorithms that can be encoded using a manual cipher -- then (given sufficient ciphertext) it is usually possible to decode the messages in less than a day using computer and a brute force attack.

### Random Number Generators

A pseudorandom number generator (PRNG) is an algorithm that generates a sequence of numbers, the elements of which are approximately independent of each other. PRNGs are an integral part of cryptography.

### Prime Number Generators

TBD

 This article is a part of CryptoDox, an attempt to build an Online Encyclopedia on Cryptography and Information Security. You are seeing this box on this page since we believe this is a stub page. Create an account for yourself on this website and start contributing content.