Research and Implementation of File Encryption and Decryption
Research and Implementation of File Encryption and Decryption
and Decryption
Abstract. Analyzed and studied on public key and private key cryptography,
studied and compared the RSA and DES algorithm, achieved a basic process of
file encryption and decryption, provided effectivly protection to document
security.
In the process of design about file encryption and decryption, the system of password is
an important guarantee for file security. In the paper, using DES encryption algorithm to
encrypt and decrypt the contents of the file operations, and using MD5 algorithm to
encrypt and decrypt the keys used in the process of transmission and preservation. It can
effectively protect the security of the content of the document, but also has a faster
processing and response speed[1].
1 Processing
File encryption process as show in Figure 1.
encryption
Content of file Encryption text
algorithm
key key
System obtained detailed information such as the passwords of user, contents of the
files, converted the passwords of user into keys with MD5 algorithm and stored into a
D. Zeng (Ed.): Advances in Computer Science and Engineering, AISC 141, pp. 165–170.
springer link.com © Springer-Verlag Berlin Heidelberg 2012
166 C. Lu and G. Xu
dictionary, in the same time, operated the contents of file according to the encryption
algorithm and password, converted the plaintext into ciphertext. Then, we can verify
the legitimacy of the user during the decryption.
File decryption process, as shown in Figure 2
In the process, according to the decrypted password user input, system compared
with the key stored in dictionary after converted by MD5 algorithm, if the same, then
the user is legitimate, and has the right to decrypt the corresponding ciphertext opera-
tion; if dnot the same, then the user is illegal, and has no right to decrypt the encrypted
file, gives the wrong password prompt[2].
In the process, provided verification of the legality of the user, and extracted en-
crypted information, restored the encrypted file with corresponding decryption algo-
rithm, to ensure effective security of the encrypted file.
2 Function Module
System mainly consists of two modules: Algorithm module and user module, as shown
in Figure 3:
Input
File opration DES MD5
information
The template is used to format your paper and style the text. All margins, column
widths, line spaces, and text fonts are prescribed; please do not alter them. You may
note peculiarities. For example, the head margin in this template measures proportio-
nately more than is customary. This measurement and others are deliberate, using spe-
cifications that anticipate your paper as one part of the entire proceedings, and not as
an independent document. Please do not revise any of the current designations[3].
Providing friendly user interface, and receiving and processing inputed information,
such as a password, file path and the operation mode, offered corresponding treatment
tips. Provided functions of file-related operations, including file creation, deletion and
obtation of the file path, and including reading and writing to file content.
DES algorithm convert 64-bit plain text into 64-bit cipher text, the flow chart shown in
Figure 4:
DES operate 64-bit plaintext block, though initial replacement, such as shown in
Table 1,assembling the 64-bit plaintext blockby bit, split it into left part and right part
by 32-bit length. Then, make 16 rounds of the same iteration, computing process
168 C. Lu and G. Xu
shown in Figure 5. In the process, the plaintext data and the key combined. After 16
rounds, left and right through the end replacement (replacement of the inverse of the
initial replacement), that is, the ciphertext.
58 50 42 34 26 18 10 2 60 52 44 36 28 20 12 4
62 54 46 38 20 22 14 6 64 56 48 40 32 24 16 8
57 49 41 33 25 17 9 1 59 51 43 35 27 19 11 3
61 53 45 37 29 21 13 5 63 55 47 39 31 23 15 7
As shown above, the process in each round, each round key bit shift, and then se-
lected 48b bits from 56, through extending replacement, extending the right side of the
data to 48-bit, and combinding 48-bit key through XOR operation, replacing 48-bit
data with new 32-bit data through eight S- boxes, then, replace one more time, called
P- box replacement.
Then, through another XOR operation, output of function F and the left part com-
bined, the results is new right half. This operation is repeated 16 times, reaching the
purpose of DES encryption[4][7].
When input password, system will calculate the password into MD5 value, and then
compare the MD5 value saved in the file system, and to determine the password is
correct. Through it, system can determine the legality of user without know the plain
code. It can prevent disclosure of user's password, and also increase the difficulty of
beeing cracked to some degree[5][8].
Research and Implementation of File Encryption and Decryption 169
After initialization, MD5 handle the input text by 512- bit block, and each divided into
16 32- seat child group. Output of algorithm consists of four 32- bit sub-groups and
cascade them to a 128 - bit hash value.
MD5 algorithm flow chart shown in Figure 6:
First fill the message, make the length small than multiple of 512-bit 64 bits. The
method is attaching 1 behind the message, padding the number with 0, and then subse-
quently attached to a 64-bit message length (before padding). The role of the steps is to
make the message length is exactly an integer multiple of 512 bits, and ensuring that
the messages are different after padding.
Four 32-bit link variables (chaining variable) is initialized to:
A=0x01234567
B=0x89abcdef
C=0xfedcba98
D=0x76543210
Then make the algorithm loop, the frequency of loop is the number of 512 bit mes-
sage groups.
copy four variables above to other variables: A to a, B to b, C to c, D to d[6].
The main loop has four rounds, each round is very similar, as shown in Figure 7.
The first round operated 16 times. In each operation, nonlinear function operating on
the three of a, b, c and d, then the result plus a fourth variable, the text of a sub-group
and a constant. The results then move to the right of a variable number of rings, plus
one of a, b, c or d. Finally, replacing one of a, b, c or d.
170 C. Lu and G. Xu
4 Conclusion
Simple small application software of encryption and decryption to file with the utility
of DES, MD5, RSA algorithm, the system can easily encrypt and decrypt a variety of
file (such as. TXT,. DOC, etc.), effectively protect and precisly restore the content of
encrypted file, protected personal information to a degree.
References
1. Lu, D.: Computer Cryptography, Computer network data privacy and security. Tsinghua
University Press (1998)
2. Li, K., Wang, D., Dong, X.: Practical Cryptography and computer data security. Northeas-
tern University Press (1997)
3. Yang, Y., Sun, W.: Modon cryptography new theory. Science Press, Beijing (2001)
4. Schneier, B.: Application Cryptography - Protocols, Algorithms and C source code. Machi-
nery Industry Press (2000)
5. Huang, Y., Chen, L., Tang, S.: Information security and encryption decryption core tech-
nology. Electronic Press (2001)
6. Li, S., Wang, D.: Modern Cryptography Theory, Method and frontier. Science Press, Bei-
jing (2009)
7. Manzanares, A.I., Sierra, C.J.M., Marquez, J.T.: On the imp lementation of security policies
with adaptative encryption. Computer Communications 29(2), 2750–2758 (2006)
8. Vaudenay, S.: On the Weak Keys of Blowfish. In: Gollmann, D. (ed.) FSE 1996. LNCS,
vol. 1039, pp. 27–32. Springer, Heidelberg (1996)