📜 ⬆️ ⬇️

Elementary cryptography

Under the cut:

Caesar cipher


Each letter is replaced by a third (or N-th) alphabetically after it.
a b c d e f g i h k l m n o p q r s t u v w x y z
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
in gde e zh and y to l m n about p r with t at f x x c w sh sh s y s ya a b
gdeo zh and y to l m n about p r with t at f x x c w w ess s e y i a b c
...
Message : Habrahabr
Code : shgdugshgdu


Cipher pairs


The alphabet is randomly written in 2 lines, and the encryption of the text occurs by replacing the letter with the next one vertically.
Example table:
W
e t x y sh y d b b s w t h h h l -
Message : Habrahabr
Code : echmlchechml


Four squares cipher


4 squares of size 5x5 or 4x4 are built (depending on the size of the alphabet). In each of them randomly write the alphabet.
')


Encryption: Selecting 2 letters of the message, we find them respectively in the upper left and lower right squares.
For the cipher we use 2 letters that form the vertices of the rectangle with the selected (from left to right)

Message : Habrahabr (ha br ah ab rr)
Code : day to day (days)


Matrix cipher


Prepare the MxN matrix.
Prepare two keys K M and K N.

1) Write the message in rows to the MxN matrix.
2) Write the keys along the edges of the matrix.
3) The rows are rearranged so that the letters of the key become ordered alphabetically.
Do the same with columns.
4) Write off the letters from the matrix in columns.

Matrix dimensions: M = 4, N = 5
Key K M : bullet, K N : fool.



Message : title should be meaningful
Code : ekozobnlddzhzhlavyamlmosaoyonoooooolnno


Code ADFGX


Letters of the Latin alphabet are written (in a definite way) into a 5x5 matrix
Use the key word (for example, formula ).



Message : one two three

1) we assign 2 letters to each letter of the message (according to the table).



2) write the resulting text under the key:



3) rearrange the columns so that the key letters are ordered alphabetically:



4) write the letters from the resulting matrix (in columns) in the cipher.

Message : one two three
Code : ADXF DDDF FAFX XDDX FXDX FGXF XFXF


Vigenera cipher


In the alphabet of length N, the operation of adding (cyclic shift) letters is introduced.



Numbered the letters, add them modulo N (for the English alphabet N = 26).



Choose a key word (let pass ) and sign it under the message how many times you need



Message : search twitter
Code : hesjrhloxtlwg



For a warm-up, I suggest that interested habrp users make a pair of ciphers and allow others to guess by first specifying the encryption method.

Source: https://habr.com/ru/post/116716/


All Articles