|
|
Line 1: |
Line 1: |
| The '''affine cipher''' is a type of [[monoalphabetic substitution cipher]], wherein each letter in an alphabet is mapped to its numeric equivalent, encrypted using a simple mathematical function, and converted back to a letter. The formula used means that each letter encrypts to one other letter, and back again, meaning the cipher is essentially a standard substitution cipher with a rule governing which letter goes to which. As such, it has the weaknesses of all substitution ciphers. Each letter is enciphered with the function <math>(ax+b)\mod(26)</math>, where <math>b</math> is the magnitude of the shift.
| | Beforehand playing a new video tutorials game, read the be unfaithful book. Most on-line games have a book you actually can purchase separately. You may want to consider doing this as well as a reading it before the individual play, or even while you are playing. This way, you could certainly get the most around of your game participate.<br><br>If you beloved this [http://www.Google.Co.uk/search?hl=en&gl=us&tbm=nws&q=article&gs_l=news article] and also you would like to obtain more info pertaining to clash of clans hack android ([http://prometeu.net Going Listed here]) i implore you to visit our web site. To comprehend coins and gems, kind obtain the Clash amongst Clans hack equipment by- clicking on the get a hold of button. Contingent for a operating framework that you are utilizing, you will go the downloaded document whilst admin. Furnish my log in Id and choose the gadget. Subsequent to this, you are enter into the quantity of gems or coins that individuals and start off one particular Clash of Clans hack instrument.<br><br>Be sure to pay attention to a mission's evaluation when purchasing a great gift. This evaluation will allow you find out what age level clash of clans hack tool is ideal for and will let you know when the sport are [http://data.Gov.uk/data/search?q=violent violent]. It figure out whether you should buy the sport.<br><br>Operating in Clash of Clans Tips (a brilliant popular ethnic architecture and arresting striking by Supercell) participants could possibly acceleration up accomplishments for instance building, advance or training troops with gems which can be bought for absolute money. They're basically monetizing the actual player's impatience. Each single amusing architecture daring Which i apperceive of manages its done.<br><br>Be certain to may not let games take over your days. Game titles can be quite additive, whenever your have to make assured you moderate the free time that you investing guitar playing such games. In case you invest an excessive volume of time playing video game, your actual life would quite possibly begin to falter.<br><br>So that you can access it into excel, copy-paste this continued equation into corpuscle B1. If you again access an majority of energy in abnormal in corpuscle A1, the bulk over treasures will arise on B1.<br><br>Experiment with to restrain your heavy gaming to only a particular kind of machine. Buying all the real consoles plus a gaming-worthy personal computer can demand up to thousands, just in hardware. Yet, most big titles definitely will be available on near all of them. Choose one platform to successfully stick with for savings. |
| | |
| ==Description==
| |
| In the affine cipher the letters of an alphabet of size <math>m</math> are first mapped to the integers in the range <math>0 .. m-1</math>. 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
| |
| :<math>\mbox{E}(x)=(ax+b)\mod{m},</math>
| |
| where modulus <math>m</math> is the size of the alphabet and <math>a</math> and <math>b</math> are the key of the cipher. The value <math>a</math> must be chosen such that <math>a</math> and <math>m</math> are [[coprime]]. The decryption function is
| |
| :<math>\mbox{D}(x)=a^{-1}(x-b)\mod{m},</math> | |
| where <math>a^{-1}</math> is the [[modular multiplicative inverse]] of <math>a</math> [[modular arithmetic|modulo]] <math>m</math>. I.e., it satisfies the equation
| |
| :<math>1 = a a^{-1}\mod{m}.</math>
| |
| The multiplicative inverse of <math>a</math> only exists if <math>a</math> and <math>m</math> are coprime. Hence without the restriction on <math>a</math> decryption might not be possible.
| |
| It can be shown as follows that decryption function is the inverse of the encryption function,
| |
| :<math>\begin{align}
| |
| \mbox{D}(\mbox{E}(x)) &= a^{-1}(\mbox{E}(x)-b)\mod{m}\\
| |
| &= a^{-1}(((ax+b)\mod{m})-b)\mod{m} \\
| |
| &= a^{-1}(ax+b-b)\mod{m} \\
| |
| &= a^{-1}ax \mod{m}\\
| |
| &= x\mod{m}.
| |
| \end{align}</math>
| |
| | |
| ==Weaknesses==
| |
| Since the affine cipher is still a monoalphabetic substitution cipher, it inherits the weaknesses of that class of ciphers. The [[Caesar cipher]] is the Affine cipher when <math>a=1</math> since the encrypting function simply reduces to a linear shift.
| |
| | |
| Considering the specific case of encrypting messages in English (i.e. <math>m=26</math>), there are a total of 286 non-trivial affine ciphers, not counting the 26 trivial Caesar ciphers. This number comes from the fact there are 12 numbers that are coprime with 26 that are less than 26 (these are the possible values of <math>a</math>). Each value of <math>a</math> can have 26 different addition shifts (the <math>b</math> value); therefore, there are 12*26 or 312 possible keys. This lack of variety renders the system as highly insecure when considered in light of [[Kerckhoffs' principle|Kerckhoffs' Principle]].
| |
| | |
| The cipher's primary weakness comes from the fact that if the cryptanalyst can discover (by means of [[frequency analysis]], brute force, guessing or otherwise) the plaintext of two ciphertext characters then the key can be obtained by solving a [[simultaneous equation]]. Since we know <math>a</math> and <math>m</math> are relatively prime this can be used to rapidly discard many "false" keys in an automated system.
| |
| | |
| The same type of transformation used in affine ciphers is used in [[linear congruential generator]]s, a type of [[pseudorandom number generator]]. This generator is not a [[cryptographically secure pseudorandom number generator]] for the same reason that the affine cipher is not secure.
| |
| | |
| ==Examples==
| |
| In these two examples, one encrypting and one decrypting, the alphabet is going to be the letters A through Z, and will have the corresponding values found in the following table.
| |
| {| class="wikitable" border="1"
| |
| |-
| |
| ! A
| |
| ! B
| |
| ! C
| |
| ! D
| |
| ! E
| |
| ! F
| |
| ! G
| |
| ! H
| |
| ! I
| |
| ! J
| |
| ! K
| |
| ! L
| |
| ! M
| |
| ! N
| |
| ! O
| |
| ! P
| |
| ! Q
| |
| ! R
| |
| ! S
| |
| ! T
| |
| ! U
| |
| ! V
| |
| ! W
| |
| ! X
| |
| ! Y
| |
| ! Z
| |
| |-
| |
| | 0
| |
| | 1
| |
| | 2
| |
| | 3
| |
| | 4
| |
| | 5
| |
| | 6
| |
| | 7
| |
| | 8
| |
| | 9
| |
| | 10
| |
| | 11
| |
| | 12
| |
| | 13
| |
| | 14
| |
| | 15
| |
| | 16
| |
| | 17
| |
| | 18
| |
| | 19
| |
| | 20
| |
| | 21
| |
| | 22
| |
| | 23
| |
| | 24
| |
| | 25
| |
| |}
| |
| | |
| ===Encrypting===
| |
| In this encrypting example,<ref>http://www.math.cornell.edu/~kozdron/Teaching/Cornell/135Summer06/Handouts/affine.pdf</ref> the plaintext to be encrypted is "AFFINE CIPHER" using the table mentioned above for the numeric values of each letter, taking <math>a</math> to be 5, <math>b</math> to be 8, and <math>m</math> to be 26 since there are 26 characters in the alphabet being used. Only the value of <math>a</math> has a restriction since it has to be coprime with 26. The possible values that <math>a</math> could be are 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, and 25. The value for <math>b</math> can be arbitrary as long as <math>a</math> does not equal 1 since this is the shift of the cipher. Thus, the encryption function for this example will be <math> y=E(x)=(5x+8)\pmod{26}</math>. The first step in encrypting the message is to write the numeric values of each letter.
| |
| {| class="wikitable" border="1"
| |
| |-
| |
| |plaintext:
| |
| | A
| |
| | F
| |
| | F
| |
| | I
| |
| | N
| |
| | E
| |
| | C
| |
| | I
| |
| | P
| |
| | H
| |
| | E
| |
| | R
| |
| |-
| |
| | x:
| |
| | 0
| |
| | 5
| |
| | 5
| |
| | 8
| |
| | 13
| |
| | 4
| |
| | 2
| |
| | 8
| |
| | 15
| |
| | 7
| |
| | 4
| |
| | 17
| |
| |}
| |
| | |
| Now, take each value of x, and solve the first part of the equation, <math>(5x+8)</math>. After finding the value of <math>(5x+8)</math> for each character, take the remainder when dividing the result of <math>(5x+8)</math> by 26. The following table shows the first four steps of the encrypting process.
| |
| | |
| {| class="wikitable" border="1"
| |
| |-
| |
| |plaintext:
| |
| | A
| |
| | F
| |
| | F
| |
| | I
| |
| | N
| |
| | E
| |
| | C
| |
| | I
| |
| | P
| |
| | H
| |
| | E
| |
| | R
| |
| |-
| |
| | x:
| |
| | 0
| |
| | 5
| |
| | 5
| |
| | 8
| |
| | 13
| |
| | 4
| |
| | 2
| |
| | 8
| |
| | 15
| |
| | 7
| |
| | 4
| |
| | 17
| |
| |-
| |
| | <math>5x+8</math>
| |
| | 8
| |
| | 33
| |
| | 33
| |
| | 48
| |
| | 73
| |
| | 28
| |
| | 18
| |
| | 48
| |
| | 83
| |
| | 43
| |
| | 28
| |
| | 93
| |
| |-
| |
| | <math>(5x+8)\pmod{26}</math>
| |
| | 8
| |
| | 7
| |
| | 7
| |
| | 22
| |
| | 21
| |
| | 2
| |
| | 18
| |
| | 22
| |
| | 5
| |
| | 17
| |
| | 2
| |
| | 15
| |
| |}
| |
| | |
| The final step in encrypting the message is to look up each numeric value in the table for the corresponding letters. In this example, the encrypted text would be IHHWVCSWFRCP. The table below shows the completed table for encrypting a message in the Affine cipher.
| |
| | |
| {| class="wikitable" border="1"
| |
| |-
| |
| |plaintext:
| |
| | A
| |
| | F
| |
| | F
| |
| | I
| |
| | N
| |
| | E
| |
| | C
| |
| | I
| |
| | P
| |
| | H
| |
| | E
| |
| | R
| |
| |-
| |
| | x:
| |
| | 0
| |
| | 5
| |
| | 5
| |
| | 8
| |
| | 13
| |
| | 4
| |
| | 2
| |
| | 8
| |
| | 15
| |
| | 7
| |
| | 4
| |
| | 17
| |
| |-
| |
| | <math>5x+8</math>
| |
| | 8
| |
| | 33
| |
| | 33
| |
| | 48
| |
| | 73
| |
| | 28
| |
| | 18
| |
| | 48
| |
| | 83
| |
| | 43
| |
| | 28
| |
| | 93
| |
| |-
| |
| | <math>(5x+8)\pmod{26}</math>
| |
| | 8
| |
| | 7
| |
| | 7
| |
| | 22
| |
| | 21
| |
| | 2
| |
| | 18
| |
| | 22
| |
| | 5
| |
| | 17
| |
| | 2
| |
| | 15
| |
| |-
| |
| | ciphertext:
| |
| | I
| |
| | H
| |
| | H
| |
| | W
| |
| | V
| |
| | C
| |
| | S
| |
| | W
| |
| | F
| |
| | R
| |
| | C
| |
| | P
| |
| |}
| |
| | |
| ===Decrypting===
| |
| In this decryption example, the ciphertext that will be decrypted is the ciphertext from the encryption example. The corresponding decryption function is <math>\mbox{D}(y)=21(y-8)\mbox{ mod }26</math>, where <math>a^{-1}</math> is calculated to be 21, <math>b</math> is 8, and <math>m</math> is 26. To begin, write the numeric equivalents to each letter in the ciphertext, as shown in the table below.
| |
| {| class="wikitable" border="1"
| |
| |-
| |
| | ciphertext:
| |
| | I
| |
| | H
| |
| | H
| |
| | W
| |
| | V
| |
| | C
| |
| | S
| |
| | W
| |
| | F
| |
| | R
| |
| | C
| |
| | P
| |
| |-
| |
| | y:
| |
| | 8
| |
| | 7
| |
| | 7
| |
| | 22
| |
| | 21
| |
| | 2
| |
| | 18
| |
| | 22
| |
| | 5
| |
| | 17
| |
| | 2
| |
| | 15
| |
| |}
| |
| | |
| Now, the next step is to compute <math>21(y-8)</math>, and then take the remainder when that result is divided by 26. The following table shows the results of both computations.
| |
| {| class="wikitable" border="1"
| |
| |-
| |
| | ciphertext:
| |
| | I
| |
| | H
| |
| | H
| |
| | W
| |
| | V
| |
| | C
| |
| | S
| |
| | W
| |
| | F
| |
| | R
| |
| | C
| |
| | P
| |
| |-
| |
| | y:
| |
| | 8
| |
| | 7
| |
| | 7
| |
| | 22
| |
| | 21
| |
| | 2
| |
| | 18
| |
| | 22
| |
| | 5
| |
| | 17
| |
| | 2
| |
| | 15
| |
| |-
| |
| | 21(y-8):
| |
| | 0
| |
| | -21
| |
| | -21
| |
| | 294
| |
| | 273
| |
| | -126
| |
| | 210
| |
| | 294
| |
| | -63
| |
| | 189
| |
| | -126
| |
| | 147
| |
| |-
| |
| | (21(y-8)) mod 26:
| |
| | 0
| |
| | 5
| |
| | 5
| |
| | 8
| |
| | 13
| |
| | 4
| |
| | 2
| |
| | 8
| |
| | 15
| |
| | 7
| |
| | 4
| |
| | 17
| |
| |}
| |
| | |
| The final step in decrypting the ciphertext is to use the table to convert numeric values back into letters. The plaintext in this decryption is AFFINECIPHER. Below is the table with the final step completed.
| |
| {| class="wikitable" border="1"
| |
| |-
| |
| | ciphertext:
| |
| | I
| |
| | H
| |
| | H
| |
| | W
| |
| | V
| |
| | C
| |
| | S
| |
| | W
| |
| | F
| |
| | R
| |
| | C
| |
| | P
| |
| |-
| |
| | y:
| |
| | 8
| |
| | 7
| |
| | 7
| |
| | 22
| |
| | 21
| |
| | 2
| |
| | 18
| |
| | 22
| |
| | 5
| |
| | 17
| |
| | 2
| |
| | 15
| |
| |-
| |
| | 21(y-8):
| |
| | 0
| |
| | -21
| |
| | -21
| |
| | 294
| |
| | 273
| |
| | -126
| |
| | 210
| |
| | 294
| |
| | -63
| |
| | 189
| |
| | -126
| |
| | 147
| |
| |-
| |
| | (21(y-8)) mod 26:
| |
| | 0
| |
| | 5
| |
| | 5
| |
| | 8
| |
| | 13
| |
| | 4
| |
| | 2
| |
| | 8
| |
| | 15
| |
| | 7
| |
| | 4
| |
| | 17
| |
| |-
| |
| | plaintext:
| |
| | A
| |
| | F
| |
| | F
| |
| | I
| |
| | N
| |
| | E
| |
| | C
| |
| | I
| |
| | P
| |
| | H
| |
| | E
| |
| | R
| |
| |}
| |
| | |
| ===Entire alphabet encoded===
| |
| To make encrypting and decrypting quicker, the entire alphabet can be encrypted to create a one to one map between the letters of the cleartext and the ciphertext. In this example, the one to one map would be the following:
| |
| {| class="wikitable" border="1"
| |
| |-
| |
| ! letter in the cleartext
| |
| ! A
| |
| ! B
| |
| ! C
| |
| ! D
| |
| ! E
| |
| ! F
| |
| ! G
| |
| ! H
| |
| ! I
| |
| ! J
| |
| ! K
| |
| ! L
| |
| ! M
| |
| ! N
| |
| ! O
| |
| ! P
| |
| ! Q
| |
| ! R
| |
| ! S
| |
| ! T
| |
| ! U
| |
| ! V
| |
| ! W
| |
| ! X
| |
| ! Y
| |
| ! Z
| |
| |-
| |
| | number in the cleartext
| |
| | 0
| |
| | 1
| |
| | 2
| |
| | 3
| |
| | 4
| |
| | 5
| |
| | 6
| |
| | 7
| |
| | 8
| |
| | 9
| |
| | 10
| |
| | 11
| |
| | 12
| |
| | 13
| |
| | 14
| |
| | 15
| |
| | 16
| |
| | 17
| |
| | 18
| |
| | 19
| |
| | 20
| |
| | 21
| |
| | 22
| |
| | 23
| |
| | 24
| |
| | 25
| |
| |-
| |
| | (5x+8)mod(26)
| |
| | 8
| |
| | 13
| |
| | 18
| |
| | 23
| |
| | 2
| |
| | 7
| |
| | 12
| |
| | 17
| |
| | 22
| |
| | 1
| |
| | 6
| |
| | 11
| |
| | 16
| |
| | 21
| |
| | 0
| |
| | 5
| |
| | 10
| |
| | 15
| |
| | 20
| |
| | 25
| |
| | 4
| |
| | 9
| |
| | 14
| |
| | 19
| |
| | 24
| |
| | 3
| |
| |-
| |
| | ciphertext letter
| |
| | I
| |
| | N
| |
| | S
| |
| | X
| |
| | C
| |
| | H
| |
| | M
| |
| | R
| |
| | W
| |
| | B
| |
| | G
| |
| | L
| |
| | Q
| |
| | V
| |
| | A
| |
| | F
| |
| | K
| |
| | P
| |
| | U
| |
| | Z
| |
| | E
| |
| | J
| |
| | O
| |
| | T
| |
| | Y
| |
| | D
| |
| |}
| |
| | |
| ===Programming examples===
| |
| Using the [[Python (programming language)|Python]] programming language, the following code can be used to create an encrypted alphabet using the Roman letters A through Z.
| |
| <source lang="python">
| |
| #Prints a transposition table for an affine cipher.
| |
| #a must be coprime to m=26.
| |
| def affine(a, b):
| |
| for i in range(26):
| |
| print chr(i+65) + ": " + chr(((a*i+b)%26)+65)
| |
| | |
| #An example call
| |
| affine(5, 8)
| |
| </source>
| |
| Or in [[Java (programming language)|Java]]:
| |
| <source lang="Java">
| |
| public void Affine(int a, int b){
| |
| for (int num = 0; num < 26; num++)
| |
| System.out.println(((char)('A'+num)) + ":" + ((char)('A'+(a*num + b)% 26)) );
| |
| }
| |
| Affine(5,8)
| |
| </source>
| |
| | |
| Or in [[Pascal (programming language)|Pascal]]:
| |
| <source lang="pascal">
| |
| Procedure Affine(a,b : Integer);
| |
| begin
| |
| for num := 0 to 25 do
| |
| WriteLn(Chr(num+65) , ': ' , Chr(((a*num + b) mod 26) + 65);
| |
| end;
| |
| | |
| begin
| |
| Affine(5,8)
| |
| end.
| |
| </source>
| |
| | |
| == See also ==
| |
| * [[Affine function]]s
| |
| * [[Atbash|Atbash code]]
| |
| * [[Caesar cipher]]
| |
| * [[ROT13]]
| |
| * [[Topics in cryptography]]
| |
| * Perl interface to [https://metacpan.org/module/Crypt::Affine "Affine cipher"]
| |
| | |
| ==References==
| |
| {{Reflist}}
| |
| ==External links==
| |
| *[http://nextprime.sitecloud.cytanium.com/cipher/affine.html Affine Cipher Calculator]
| |
| | |
| {{Cryptography navbox | classical}}
| |
| | |
| {{DEFAULTSORT:Affine Cipher}}
| |
| [[Category:Classical ciphers]]
| |
Beforehand playing a new video tutorials game, read the be unfaithful book. Most on-line games have a book you actually can purchase separately. You may want to consider doing this as well as a reading it before the individual play, or even while you are playing. This way, you could certainly get the most around of your game participate.
If you beloved this article and also you would like to obtain more info pertaining to clash of clans hack android (Going Listed here) i implore you to visit our web site. To comprehend coins and gems, kind obtain the Clash amongst Clans hack equipment by- clicking on the get a hold of button. Contingent for a operating framework that you are utilizing, you will go the downloaded document whilst admin. Furnish my log in Id and choose the gadget. Subsequent to this, you are enter into the quantity of gems or coins that individuals and start off one particular Clash of Clans hack instrument.
Be sure to pay attention to a mission's evaluation when purchasing a great gift. This evaluation will allow you find out what age level clash of clans hack tool is ideal for and will let you know when the sport are violent. It figure out whether you should buy the sport.
Operating in Clash of Clans Tips (a brilliant popular ethnic architecture and arresting striking by Supercell) participants could possibly acceleration up accomplishments for instance building, advance or training troops with gems which can be bought for absolute money. They're basically monetizing the actual player's impatience. Each single amusing architecture daring Which i apperceive of manages its done.
Be certain to may not let games take over your days. Game titles can be quite additive, whenever your have to make assured you moderate the free time that you investing guitar playing such games. In case you invest an excessive volume of time playing video game, your actual life would quite possibly begin to falter.
So that you can access it into excel, copy-paste this continued equation into corpuscle B1. If you again access an majority of energy in abnormal in corpuscle A1, the bulk over treasures will arise on B1.
Experiment with to restrain your heavy gaming to only a particular kind of machine. Buying all the real consoles plus a gaming-worthy personal computer can demand up to thousands, just in hardware. Yet, most big titles definitely will be available on near all of them. Choose one platform to successfully stick with for savings.