In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >
Share
Shulou(Shulou.com)06/01 Report--
In many textbooks, the definitions of row replacement password and column replacement password are not exactly the same, and even the core ideas are not the same at all. Based on my own learning experience, the author briefly introduces a so-called "line permutation password" algorithm in some textbooks, and we communicate and discuss it together.
With this encryption method, plaintext is filled in a matrix in rows, while plaintext is read and generated in columns in a predetermined order. For example, if the matrix has four columns and five rows, the clear text "encryption algorithm" (with spaces left out) can be written to the matrix as follows:
2314encryptionalgorithms
Read the columns in a certain order to generate ciphertext.
For this example, if the reading order is incremental, the plaintext is: "ctarm eyogt npnoh rilis" (spaces are added just for observation). The key of this encryption is the number of columns and the order in which the columns are read. If there are a large number of columns, it may be difficult to remember, so it can be expressed as a keyword whose length is equal to the number of columns, and its alphabetical order determines the order in which the columns are read.
For example, the keyword "general" has seven letters, which means that the matrix has seven columns. Since "a" is the lowest alphabetical order in "general", the number 1 is placed in column 6; from left to right, the first "e" is second, so the number 2 is placed in column 2; and the second "e" places the number 3 in column 4. The final order is as follows:
G e n e r a l
4 2 6 3 7 1 5
_
This scheme is to write the message in a rectangle, row by row, and read the message off, column by column, but permute the order of the columns.The order of the columns then becomes the key to the algorithm.For example
Key: 4 3 1 2 5 6 7
Plaintext: a t t a c k p
O s t p o n e
D u n t i l t
W o a m x y z
Ciphertext: ttna aptm tsuo aodw coix knly petz (again, spaces are just for observation)
Thus, in this example, the key is 4312567.To encrypt, start with the column that is labeled 1, in this case column 3. Write down all the letters in that column.
*
The above is an encryption, and the above ciphertext can also be regarded as the plaintext of a new round of encryption, and line replacement encryption can be carried out again.
Reference:
"Cryptography and Network Security Principles and Practice, Fifth Edition"
-William Stallings
"Classical And Contemporary Cryptology"-Richard Spillman
Line replacement password on / / Z26 # include#include#include#includeint length;// plaintext length char plain [100000]; char cipher [100000]; char out [100000]; int int done_key / key length int key [100000]; / / key int done_key [100] = {0}; / / whether the tag has been converted to a numeric int num_key [100000] = {0}; / / convert the key to a numeric int num [100000] / / temporary matrix, containing the subscript sequence number void gen () that increments the order; / / key generation algorithm void encryption (); void decryption (); int length_str (int a []); int main () {int iposit file * fp;fp=fopen ("plain.txt", "r"); fscanf (fp, "% s", plain); / / read from file to plaintext fclose (fp); length=strlen (plain); gen (); encryption (); printf ("above correct") Decryption (); for
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.