- Scan QR code
- UTF-16LE
- UTF-32LE
- US-ASCII
- ISO-8859-1 (Latin-1)
- ISO-8859-15 (Latin-9)
- Windows-1252
- ISO-8859-2 (Latin-2)
- Windows-1250
- ISO-8859-3 (Latin-3)
- ISO-8859-4 (Latin-4)
- ISO-8859-13 (Latin-7)
- Windows-1257
- Shift_JIS
- EUC-JP
- ISO-2022-JP (JIS)
- GB2312 (EUC-CN)
- GB18030
- Big5-HKSCS
- EUC-KR (KS X 1001)
- ISO-2022-KR
- ISO-8859-5
- Windows-1251
- KOI8-R
- KOI8-U
- ISO-8859-6
- Windows-1256
- ISO-8859-7
- Windows-1253
- ISO-8859-8
- Windows-1255
- ISO-8859-9 (Latin-5)
- Windows-1254
- TIS-620
- Windows-874
- Windows-1258
Decoded
Affine |
A
B
|
---|
Encoded
Affine |
A
B
|
---|
About Affine Cipher
Affine cipher is one of the single transliteration ciphers that encrypts by replacing the characters in the text with other characters.
Character replacement is performed using the following formula.
E(x) = (ax + b) mod m
m represents the type of character to convert. x is a letter replaced by a number from 0 to m - 1. a and bb are the encryption keys.
For example, for the 26 alphabetic characters "ABCDEFGHIJKLMNOPQRSTUVWXYZ", m = 26 and x is 0 to 25 with A to Z replaced by numbers.
Character | 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 |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
x | 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 |
If a = 5, b = 3, it will be encrypted in the following flow.
Plain text | S | E | C | R | E | T |
---|---|---|---|---|---|---|
x | 18 | 4 | 2 | 17 | 4 | 19 |
(5x + 3) | 93 | 23 | 13 | 88 | 23 | 98 |
(5x + 3) mod 26 | 15 | 23 | 13 | 10 | 23 | 20 |
Cipher text | P | X | N | K | X | U |
The result of encrypting all letters with a = 5, b = 3 is as follows.
Plain : ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher: DINSXCHMRWBGLQVAFKPUZEJOTY
Specifying a = 1, b = -3 gives the Caesar cipher, specifying a = 1, b = 13 gives the same result as ROT13, and specifying a = -1, b = -1 gives the same result as the Atbash cipher.
a must specify a number of co-prime with m . This means that the only number that divides a and m must be 1. For example, a = 4, m = 26 cannot be specified because it is divisible by 2 as well as 1. In DenCode, if given an invalid a , it returns the original character without conversion.
Other language support
In addition to Latin letters, Cyrillic and Japanese Hiragana / Katakana are supported.
The results of encryption with a = 5 and b = 3 are as follows.
Cyrillic
Plain : АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ Cipher: ГИНТЧЬБЖЛРХЪЯДЙОУШЭВЗМСЦЫАЕКПФЩЮ
m = 32 (32 characters).
Japanese Hiragana / Katakana
Plain : ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんゔ Cipher: いぉぎこじそぢでぬぱぶほむゅりわゔぅおくごすぞっとねひぷぼめゆるゐぁうかぐさずたつどのびへぽもょれゑあぇがけざせだづなはぴべまゃよろをぃえきげしぜちてにばふぺみやらゎん
Plain : ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴ Cipher: イォギコジソヂデヌパブホムュリワヴゥオクゴスゾットネヒプボメユルヰァウカグサズタツドノビヘポモョレヱアェガケザセダヅナハピベマャヨロヲィエキゲシゼチテニバフペミヤラヮン
The character order is the Unicode definition order. Please note that "ゕ", "ゖ", "ヵ", "ヶ", "ヷ", "ヸ", "ヹ", and "ヺ" are not subject to encryption.
m = 84 (84 characters).