谭锴 《 Linux
环境下的密文聊天系统的设计与实现 》 第
1
页 共
32
页
Linux环境下的密文聊天系统的设计
与实现
学生姓名:谭锴 指导老师:侯利娟
摘 要 随着计算机的不断普及和互联网技术在全球领域的高速发展。越来越多的
人使用到了聊天程序。聊天程序给人们带来通信便利的同时也存在着一些安全隐
患,传统的聊天程序以明文方式传送聊天内容,这样就给一些用心不良的人大开
方便之门。本系统正是基于以上原因而设计的加密聊天程序。聊天程序采用服务
器/客户端模式。在Linux环境下采用socket套接口编程,服务器程序以创建线程
池的方式为每一个客户服务。聊天内容由服务器转发。在聊天程序中加入了对称
加密算法DES和非对称加密算法RSA。其基本实现是由服务器端生成RSA的公钥
和私钥,由客户端生成DES对称密钥,服务器端传送公钥至客户端加密DES密钥
之后回传服务器,服务器再用本地的私钥解密获得DES密钥。此后双方的通信由
DES密钥加密后传送,这样既能高效的加密明文又能在信道上安全的传送密钥使
得密钥间的共享成为现实。
关键词 对称加密算法;非对称加密算法;会话密钥;聊天系统
T h e D e s i g n a n d i m p l e m e n t a t i o n o f e n c r y p t e d c h a t
system based on Linux
Student name: TAN Kai Advisor:HOU Li-juan
A b s t r a c t A l o n g w i t h C o m p u t e r b e c o m i n g m o r e a n d m o r e p o p u l a r a n d I n t e r n e t
t e c h n o l o g y d e v e l o p i n g r a p i d l y , a l o t o f P e o p l e b e g a n t o u s e t h e I M ( c h a t
p r o g r a m ). C h a t p r o g r a m b r i n gs p e o p l e m o r e c o n v e n i e n c e , b u t a t t h e s a m e t i m e ,
sec ur i t y problem e x i sted. The tr a d i t ional chat p r o g r a m send s t h e m e s s a g e b y p l a i n
text, which open the door for the bad man. This encrypted chat system is right based
o n t h e p o i n t . T h e s y s t e m i s i n C / S ar c h i t e c t u r e u s i n g s o c k e t b a s e d o n L i n u x . T h e
server program serves each client in the way of establishing thread and is responsible
to transfer message. The DES algorithm and RSA alg orithm are used to encrypt in
t h i s p r o g r a m. Th e b a s i c p r i n c i p l e i s t h a t t h e s erv e r g e n e r a t es R S A p u b l i c k e y a n d