Caesar TC's crack programming
Caesar TC's crack programming achieves recent security development, more and more important for cryptography, although we now use non-symmetric cryptosystems, but at the same time due to some important reasons, the traditional password is still in A large number of uses, such as shift, alternative basic thinking still has no change, I personally think that in the future, we will spend a lot of time to study the cryptography, so that we can promote our e-government, electronics The healthy development of business, the following I want to talk about the decryption of a classical password ---- Caeser password, which is to find its encryption key, thus decrypt, because it is a symmetric password The system, the add-on key is the same, and the following is simple to decrypt the encryption process: ciphertext: c = m k (MOD 26) Decryption process: clear text: m = ck (MOD 26) For detailed procedures, please refer to the relevant information The characteristics of probability statistics are mainly used when cracking, and the probability of e-letters is the largest.
The encrypted program is not to say, the following focuses on the process of decryption: I use C, I'm using C, I'm going to try the correct time in VC6.0, "stdio.h" #include "ctype.h" #include "stdlib.h" main (int Argc, char * argv []) {file * fp_ciper, * fp_plain; // Cipheet and plaintext file pointer char ch_ciper, ch_plain; int i, temp = 0; // i is used Save the maximum number of subscripts // TEMP with int key; // key INT J; int Num [// key INT J; INT NUM [26]; / / Save the number of letters in ciphertext (i = 0; i <26; i ) NUM = 0; // Permerates the initialization of the NUM [] array "Printf (" ================================ ======================== n "); Printf (" ----------------- by Amei Hong Design ------------------ N "); Printf (" ===================== ================================= n "); if (argc! = 3) {Printf (" this is Kaiser Decryption Usage: [File Name] [Ciphertext] N "); Printf (" such as: decryption f: Ciper_2_1.txt f: plain.txtn);} // Decision program input parameter is correct if IF ((fp_ciper = fopen (argv [1], "r")) == null) {printf ("Open Ciphertext error! Decryption failed N"); exit (0);} while ((ch_ciper = fgetc (fp_ciper) )! = EOF) Switch (CH_CIPER) {CASE 'A': Num [0] = NUM [0] 1; Break; // Statistics Ciphertext Alphase Case 'B': Num [1] = NUM [ 1] 1; Break; //, same case 'c': Num [2] = NUM [2] 1; Break; Case 'D': Num [3] = Num [3] 1 Break; Case 'E': Num [4] = NUM [4] 1; Break; Case 'f': Num [5] = NUM [5] 1; Break; Case 'g'
: Num [6] = NUM [6] 1; Break; Case 'h': Num [7] = NUM [7] 1; Break; Case 'I': Num [8] = NUM [8] 1 Break; Case 'J': Num [9] = NUM [9] 1; Break; Case 'K': Num [10] = NUM [10] 1; Break; Case 'L': Num [11] = NUM [11] 1; Break; Case 'M': Num [12] = NUM [12] 1; Break; Case 'N': Num [13] = NUM [13] 1; Break; Case ' 0 ': NUM [14] = NUM [14] 1; Break; Case' P ': Num [15] = NUM [15] 1; Break; Case' q ': Num [16] = Num [16] 1; Break; Case 'R': Num [17] = NUM [17] 1; Break; Case 's': Num [18] = NUM [18] 1; Break; Case 'T': NUM [ 19] = NUM [19] 1; Break; Case 'u': Num [20] = NUM [20] 1; Break; Case 'V': Num [21] = NUM [21] 1; Break; Case 'W': Num [22] 1; Break; Case 'x': Num [23] = NUM [23] 1; Break; Case 'Y': Num [24] = NUM [ 24] 1; Break; Case 'Z': Num [25] = NUM [25] 1; Break;} fclose (fp_ciper); for (i = 0; i <26; i ) IF (Num> Temp) {j = i; // Since the maximum number of lower subscripts TEMP = Num;}} (j <5) key = (j 1 26) -5; // is calculated according to the first alphabet / / Rather than pressing the subscript, so add 1 //5 refers to the order ELSE Key = (J 1) -5 in the alphabet;