The younger brother graduation design is "the application and software development of chaotic synchronization in confidential communications". Since the programming is not enough, now I have problems on C language programming, and if you don't solve it, you want everyone to have a little clue. I told me, email: gdlc@163.net. Ten million Thanks! The core of chaos is "Butterfly Effect" (the meaning of butterfly effect is said: Beijing's butterfly fan is fanned, will cause a storm in New York), this butterfly interpretation of graphics is scientific as Lorenz The attractor is determined by a nonlinear equation group below: DX / DT = -ax ay DY / DT = -xz bx-y dz / dt = XY-CZ (A, B, C as parameters) We can use numerical methods Solving this equation, I use Eliva to take out a series of numbers, where x is between -25 to 25, as our confidential signal. I will first be static encryption, that is, the encrypted side and the decision signal are the same, the procedure is as follows: Envelope: #include
Main () {file * fp1, * fp2; char in_fname [30]; / * Enter the file name to encrypted * / char output_fname [30]; / * Enter the encrypted file name * / float ch; float x0 = 1 , y0 = 1, z0 = 1; / * initial value * / float a = 16.0, b = 45.92, c = 4.0; float x, y, z; float t = 0.00001; / * Eucalytics long*/
Printf ("/ n Please enter the file name to encrypted: / n"); gets (in_fname); / * Get the file name to encrypted * /
Printf ("Please enter the encrypted file name: / n"); gets (out_fname); / * Get the file name after encryption * /
FP1 = FOPEN (IN_FNAME, "RB"); if (fp1 == null) {Printf ("canNot Open in-file./N"); exit (1); / * If you cannot open the file to encrypted, you will exit Program * /} fp2 = fopen (OUT_FNAME, "WB"); if (fp2 == null) {printf ("Cannot OR CREATE OUT-FILE./N); EXIT (1); / * If you cannot establish an encryption After the file, you will exit * /}
/ * Encryption algorithm start * / while (fEOf (fp1)) {ch = fgetc (fp1); x = x0 t * a * Y0-T * a * x0; y = Y0 T * b * x0-t * X0 * Z0-T * Y0; z = z0 t * x0 * Y0-T * C * Z0;
FPUTC (CH X, FP2); / * Added FP2 file * / x0 = x; y0 = y; z0 = z;} fclose (fp1); fclose (fp2);} Decipheral only need to put FPUTC (CH X, FP2) This is FPUTC (CH-X, FP2), static only adds a set of numbers in the encrypted side, then subtracting this set of numbers in the decryption end, does not involve too many programs The problem, so it is very good. When I am moving synchronously, I started to encounter problems. When synchronization, decrypt the following changes: DX / DT = -ax AY, DY / DT = -SZ BS-Y, DZ / DT = SY-CZ (A, B, C is The parameter), that is, the X in the DY / DZ / DZ is replaced by S is the file obtained after encryption. The encrypted end program is constant, the decryption is: #include
Main () {file * fp1, * fp2; char in_fname [30]; / * Enter file name to decrypt * / char output_fname [30]; / * Enter the decrypted file name * / float ch; float x0 = 1 , Y0 = 1, z0 = 1; float a = 16.0, b = 45.92, c = 4.0; float x, y, z; float t = 0.00001;
Printf ("/ n Please enter the file name to decrypt: / n"); gets (in_fname); / * Get the file name to decrypted * /
Printf ("Please enter the decrypted file name: / N"); gets (out_fname); / * Get the file name of the decrypted file * /
FP1 = FOPEN (IN_FNAME, "RB"); if (fp1 == null) {Printf ("canNot Open in-file./N"); exit (1); / * If you cannot open the file to decrypted, you withdraw Program * /} fp2 = fopen (OUT_FNAME, "WB"); if (fp2 == null) {Printf ("cannot open or create out-file./n); exit (1); / * If you cannot establish a decryption After the file, you will exit * /}
/ * Solution Algorithm start * / while (fEOf (fp1)) {ch = fgetc (fp1); x = x0 t * a * Y0-t * a * x0; y = Y0 T * b * ch-t * C * CH * Z0-T * Y0; z = z0 t * CH * Y0-T * C * Z0;