alphabet
- English (ABCDEFGHIJKLMNOPQRSTUVWXYZ).
key
- positive numbers (all other characters are ignored).
string Encrypt(string plaintext, string key)
Encrypts plaintext with a cipher "Rail-Fence" with the specified key.
plaintext
- the text to be encrypted.
key
- fence height.
The ciphertext
.
string Decrypt(string ciphertext, string key)
Decrypts ciphertext with a cipher "Rail-Fence" with the specified key.
ciphertext
- the text to decrypt.
key
- fence height.
Decrypted text
.
- Build a key-tall "rail fence".
- Read characters from left to right from top to bottom.
key = 3
plaintext = "HELLOWORLD"
H O L
E L W R D
L O
ciphertext = HOLELWRDLO"
In order to decrypt the received text, it is necessary perform the reverse actions performed during encryption and use the same key.
alphabet
- English (ABCDEFGHIJKLMNOPQRSTUVWXYZ).
key
- array of holes in the grill.
public RotatingGrill()
{
key[0] = new int[2] { 0, 0 };
key[1] = new int[2] { 3, 1 };
key[2] = new int[2] { 2, 2 };
key[3] = new int[2] { 1, 3 };
}
Initializes the key with a default value.
0 X X X
X X X 0
X X 0 X
X 0 X X
public RotatingGrill(int[][] key, int grillSize)
{
this.key = key;
this.grillSize = grillSize;
}
Allows you to create your own grill with your own key.
string Encrypt(string plaintext, string key = null)
Encrypts text using the "rotating grill" algorithm.
plaintext
- the text to be encrypted.
key
- specified when creating the object.
The ciphertext
.
string Decrypt(string ciphertext, string key = null)
Decrypts the text using the "rotating grill" algorithm.
ciphertext
- the text to decrypt.
key
- specified when creating the object.
Decrypted text
.
- Write the letters of the plaintext in free holes..
- Rotate the grill 90 degrees.
- Perform steps 1, 2 until you encrypt all the text.
Perform reverse encryption actions.
alphabet
- Russian (АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ).
key
- characters of the Russian alphabet (all other characters are ignored).
The implementation of this cipher is made with a progressive key
.
public Vigenere()
{
alphabet = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЪЫЬЭЮЯ";
}
Initializes the alphabet to the default value.
public Vigenere(string alphabet)
{
this.alphabet = alphabet;
}
Allows you to set your own alphabet.
string Encrypt(string plaintext, string key)
Encrypts text using the "Vigenere" algorithm.
plaintext
- the text to be encrypted.
key
- the key for the lookup table.
The ciphertext
.
string Decrypt(string ciphertext, string key)
Decrypts text using the "Vigenere" algorithm.
ciphertext
- the text to decrypt.
key
- the key for the lookup table.
Decrypted text
.
- Select a lookup table according to the current key characters.
- Substitute a character with the character from the lookup table for the current plaintext character.
Perform reverse encryption actions.