One of the FoxPro of the Database Causes and Decryption Technology

zhaozj2021-02-16  46

FOXPRO one piece of the database encryption and decryption technology: CCBZZP

In reality, the security of data is important, especially the department that is very important as a confidentiality such as banks, so the encryption of data is particularly important, and the author summarizes the encryption and decryption of various databases in long-term applications. Writing, I hope to help everyone, and also discuss with everyone, learn together, make progress together!

FoxPro provides users with some low-level file operation functions, using these low-level operational functions users to implement the operation of low-level files, these low-level functions are: fclose (), fcreate (), feof (), ferror (), fflush (), FGETS (), FOPEN (), FPUTS (), FREAD (), FSeek (), strtofile (), etc. These functions are not specifically described here, and these functions are utilized in the following articles. of.

Encrypt data

The following is to modify the password of a user as an example:

Click () content: chang_password's CLICK ():

If VARTYPE (M.ID_MAN) <> 'c' .or. Vartype (m.id_psd) <> 'c' = messagebox ('妳 妳 has not registered! Cannot change password,', 0 48 0, 'information Tip! ') = 6 Returnelse SELECT & FATHER_TABLE. LOCATE for AllTrim (id_man) == Alltrim (m.id_man); .and.

Alltrim (this.Parent.Encrypt_data.click (id_psd, m.id_man)) == Alltrim (m.id_psd); .and.! Deleted () if Found () if alltrim (m.new_password1) == Alltrim (m. New_password2) Replace & Father_Table..ID_PSD with

This.parent.Encrypt_data.click (m.new_password1, m.id_man) = messagebox ('password change is successful!', 0 48 0, 'Information Tips!') Else = MessageBox ('Password No change! Two new The password is inconsistent! ', 0 48 0,' Information Tips!

') Endif else = messagebox (' password is not changed! Old password error! ', 0 48 0,' Information Tips! ') Endifendifthis.parent.release ()

Click () content of program encrypt_data:

LPARAMETERS encrypt_password, encrypt_chrencrypt_chr = ALLTRIM (UPPER (encrypt_chr)) encrypt_chr1 = '340821960120581'encrypt_long = LEN (encrypt_chr1) encrypt_chr2 = LEFT (encrypt_chr encrypt_chr encrypt_chr encrypt_chr, encrypt_long) THIS.return_data =' 'FOR i = 1 TO encrypt_long STEP 1Alteration_chr = CHR (Bitxor (Subst (Encrypt_chr1, I, 1)), ASC (Subst (Encrypt_chr2, I, 1)))))))))))

THIS.RETURN_DATA = this.return_data chr (Bitxor (subst (subst (Encrypt_Password, i, 1)), ASC (Alteration_Chr))) endforreturn this.return_data

2. Encrypt the database file, if there is a database file C: /Users.dbf;

Handle1 = fopen ("c: /users.dbf") if Handle1 <0 MessageBox ("Did not find a specified file ...", 0 64, "Information Tips!") ReturnendiFi = 1Handle2 = Fcreate ("C: / users) .Dbf ") do while.t. = Fseek (handle1, i * 32) retasc = fread (Handle1, 32) IF ASC (Retasc) = 13 exit endif i = i 1ENDDO = FSEEK (Handle1, 0) Retstr = FREAD (Handle, I * 32) = fwrite (Handle2, Retstr) x = i * 32J = 0do while .not. Feof (Handle1) = fseek (Handle1, X J) Retasc = FREAD (Handle1, 1) IF ASC (Retasc) )> 253 CH = CHR (255-ASC)) ELSE CH = CHR (ASC (Retasc) 2) endif = fwrite (Handle2, CH) J = J 1ENDDOMESSAGEBOX ("Encryption success ...", 0 64, "Information Tips!") = Fclose (Handle1) = fclose (Handle2) Return

3. Decrypt the database file, if there is a database file C: /Users.dbf;

Handle1 = fopen ("c: /users.dbf") if Handle1 <0 MessageBox ("Did not find a specified file ...", 0 64, "Information Tips!") ReturnendifHandle2 = FcReate ("c: /users.dbf ") I = 1do while .t. = Fseek (Handle1, i * 32) Retasc = FREAD (Handle1, 32) IF ASC (Retasc) = 13 EXIT Endif i = i 1ENDDO = fseek (Handle1, 0) Retstr = FREAD (Handle, I * 32) = fwrite (Handle2, Retstr) x = i * 32J = 0do while .not. Feof (Handle1) = fseek (Handle1, X J) Retasc = FREAD (Handle1, 1) IF ASC (Retasc) <2 CH = CHR (255-ASC)) ELSE CH = CHR (ASC (Retasc) -2) endif = fwrite (Handle2, CH) J = J 1ENDDMESSAGEBOX ("Decryption success ...", 0 64, "Information Tips!") = Fclose (Handle1) = fclose (Handle2) Return

If you want to reprint, please indicate it.

to be continued...

转载请注明原文地址:https://www.9cbs.com/read-24763.html

New Post(0)