c語(yǔ)言課程設(shè)計(jì)-文件加密解密(含源代碼)_第1頁(yè)
c語(yǔ)言課程設(shè)計(jì)-文件加密解密(含源代碼)_第2頁(yè)
c語(yǔ)言課程設(shè)計(jì)-文件加密解密(含源代碼)_第3頁(yè)
c語(yǔ)言課程設(shè)計(jì)-文件加密解密(含源代碼)_第4頁(yè)
c語(yǔ)言課程設(shè)計(jì)-文件加密解密(含源代碼)_第5頁(yè)
已閱讀5頁(yè),還剩6頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、C語(yǔ)言課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告實(shí)驗(yàn)名稱(chēng):文件加密解密院系:軟件學(xué)院 學(xué)號(hào):日期:2012年9月3日9月17日 一:設(shè)計(jì)題目1:設(shè)計(jì)圖形用戶(hù)界面。2:對(duì)文件進(jìn)行加密并對(duì)加密文件進(jìn)行保存。3:對(duì)加密了的文件進(jìn)行解密。 二:設(shè)計(jì)過(guò)程設(shè)計(jì)過(guò)程中遇到的困難和解決方法:1:不能很好地理解題意(通過(guò)老師的講解)。2:不知道如何設(shè)計(jì)加密解密程序(通過(guò)翻閱書(shū)籍和上網(wǎng)查找資料)過(guò)程:首先通過(guò)學(xué)習(xí)老師提供的資料了解大致的設(shè)計(jì)過(guò)程并懂得運(yùn)用一些以前沒(méi)有學(xué)習(xí)過(guò)的c語(yǔ)言。先利用文本文件設(shè)計(jì)出加密解密的主要過(guò)程并能運(yùn)行。知道如何運(yùn)用fopen將原文件打開(kāi)并用fread將原文件內(nèi)容讀出來(lái),然后進(jìn)行加密設(shè)計(jì)并將加密的數(shù)據(jù)用fwrite

2、寫(xiě)進(jìn)指定的文件中并保存。然后讀出加密的文件并解密并保存。最后在寫(xiě)出的程序中加入圖形用戶(hù)界面,運(yùn)用window,box,gotoxy等進(jìn)行設(shè)計(jì)。 三:源代碼#include /* 標(biāo)準(zhǔn)輸入、輸出函數(shù) */#include /* 標(biāo)準(zhǔn)庫(kù)函數(shù) */#include /*字符串處理函數(shù) */#include /* 字符操作函數(shù) */#include #include #define key_down 80 #define key_up 72 #define key_esc 1 #define key_enter 28#define SIZE 1void box(int startx,int start

3、y,int high,int width);int get_key();char buf20*20*4;/*/加密解密 */void fun(char *list,char *sd) /*加密過(guò)程*/ FILE *fp1,*fp2; char buf1000; /*文件臨時(shí)存放處*/ register int ch; fp1=fopen(e:list.txt,r); /*用可讀方式打開(kāi)文件*/ fp2=fopen(e:sd.txt,w); /*用可寫(xiě)方式創(chuàng)建一個(gè)文件*/ if(fp1=NULL) printf(cannot open filen); exit(1); if(fp2=NULL)

4、printf(cannot build filen); exit(1); ch=fgetc(fp1); /*讀出打開(kāi)文件的光標(biāo)處的一個(gè)字符*/ while(!feof(fp1) /*讀出的字符不是最后的字符*/ ch=ch1; /*解密方式*/ fputc(fh,fp3); /*解密的字符存放在指定的地方*/ fh=fgetc(fp2); fread(buf1,sizeof(buf1),1,fp3); /*讀出buf1中所存放的數(shù)據(jù)*/ printf(%s,buf1); void main() int k; char *f=jiami,jiemi; /*界面的形式/ int key,y; in

5、t j,q; char list300; char sd300; char ds300; char ch,fh; char buf1000; char buf11000; FILE *fp1; FILE *fp2; int l1,l2; window(1,1,80,25); /*left,top,right,bottom,相對(duì)于屏幕的字符坐標(biāo),屏幕原點(diǎn)在左上角*/ gettext( 20,10,40,14,buf); /*保存矩形屏幕上的字符*/ textbackground(7); /*背景顏色*/ textcolor(0); /*字體顏色*/ clrscr(); /*清除矩形屏幕上的所有字

6、符*/ gotoxy(24,10); /*將當(dāng)前字符屏幕的光標(biāo)位置移動(dòng)到x,y的坐標(biāo)位子*/ printf(%s,f0); gotoxy(24,14); printf(%s,f1); gettext(10,8,60,16,buf); box(22,9,3,30); /*建立一個(gè)小窗口*/ key=0; while(1) while(bioskey(1)=0); /*讀取鍵盤(pán)值查詢(xún)鍵盤(pán)是否按下*/ key=get_key(); /*按下了什么鍵盤(pán)*/ if(key=key_up|key=key_down) y=wherey(); /*得到字符模式下窗口光標(biāo)的x坐標(biāo)數(shù)值*/ if(key=key_

7、up) y=y=10? y+4:10; /*當(dāng)y=10光標(biāo)向下移動(dòng)四個(gè)位置否則將光標(biāo)移動(dòng)到y(tǒng)=10處*/ if(key=key_down) y=y=14? y-4:14; /*當(dāng)y=14光標(biāo)向下移動(dòng)四個(gè)位置否則將光標(biāo)移動(dòng)到y(tǒng)=14處*/ puttext(10,8,60,16,buf); /*將gettext函數(shù)保存的字符恢復(fù)到屏幕上 */ gotoxy(24,y); if(y=10) textbackground(7); textcolor(0); box(22,9,3,30); textbackground(3); textcolor(15); gotoxy(24,y); cprintf(%

8、s,f0); else textbackground(7); textcolor(0); box(22,13,3,30); textbackground(3); textcolor(15); gotoxy(24,y); cprintf(%s,f1); if(key=key_enter&y=10)且光標(biāo)在y=10處 /*當(dāng)按下enter鍵且光標(biāo)在y=10處進(jìn)行下步*/ clrscr(); textbackground(3); textcolor(15); /*clrscr(); */ gotoxy(24,5); printf(input the file name for jiamin);/*用

9、戶(hù)給需要加密的文件加密 */ l1=strlen(input the file name for jiami:); /*待求長(zhǎng)度的字符串指針*/ gotoxy(24+l1,5); scanf(%s,list); gotoxy(24,10); printf(input file name for saven);/*給加密后的文件命名,并保存*/ l2=strlen(input file name for save:); gotoxy(24+l2,10); scanf(%s,sd); fun(list,sd); fp1=fopen(e:sd.txt,rb); fread(buf1,sizeof(b

10、uf1),1,fp1); gotoxy(10,15); printf(%sn,buf1); getch(); printf(file haven jiami ,save now); getche(); break; if(key=key_enter&y=14) clrscr(); textbackground(3); textcolor(15); gotoxy(24,5); printf(input the file name for jiemi n);/*用戶(hù)給需要解密的文件解密 */ l1=strlen(input the file name for jiemi: ); gotoxy(24

11、+l1,5); scanf(%s,sd); gotoxy(24,10); printf(input file name for save:n);/*對(duì)解密的文件系統(tǒng)又可以提供保存路徑 */ l2=strlen(input file name for save: ); gotoxy(24+l2,10); scanf(%s,ds); man(sd,ds); fp2=fopen(e:ds.txt,rb); fread(buf1,sizeof(buf1),1,fp2); gotoxy(10,15); printf(%sn,buf1); getch(); printf(file haven jiemi,

12、save now); getche(); break; window(1,1,80,25); gettext( 20,10,40,14,buf); textbackground(7); textcolor(0); clrscr(); gotoxy(24,10); printf(%s,f0); gotoxy(24,14); printf(%s,f1); gettext(10,8,60,16,buf); box(22,9,3,30); key=0; while(1) while(bioskey(1)=0); key=get_key(); if(key=key_up|key=key_down) y=

13、wherey(); if(key=key_up) y=y=10? y+4:10; if(key=key_down) y=y=14? y-4:14; puttext(10,8,60,16,buf); gotoxy(24,y); if(y=10) /*光標(biāo)在10處的窗口*/ textbackground(7); textcolor(0); box(22,9,3,30); textbackground(3); textcolor(15); gotoxy(24,y); cprintf(%s,f0); else textbackground(7); textcolor(0); box(22,13,3,3

14、0); textbackground(3); textcolor(15); gotoxy(24,y); cprintf(%s,f1); if(key=key_enter&y=10) clrscr(); textbackground(3); textcolor(15); /*clrscr(); */ gotoxy(24,5); printf(input the file name for jiamin);/*用戶(hù)給需要加密的文件加密 */ l1=strlen(input the file name for jiami:); gotoxy(24+l1,5); scanf(%s,list); got

15、oxy(24,10); printf(input file name for saven);/*給加密后的文件命名,并保存*/ l2=strlen(input file name for save:); gotoxy(24+l2,10); scanf(%s,sd); fun(list,sd); fp1=fopen(e:sd.txt,rb); fread(buf1,sizeof(buf1),1,fp1); gotoxy(10,15); printf(%sn,buf1); getch(); printf(file haven jiami ,save now); getche(); if(key=k

16、ey_enter&y=14) clrscr(); textbackground(3); textcolor(15); gotoxy(24,5); printf(input the file name for jiemi n);/*用戶(hù)給需要解密的文件解密 */ l1=strlen(input the file name for jiemi: ); gotoxy(24+l1,5); scanf(%s,sd); gotoxy(24,10); printf(input file name for save:n);/*對(duì)解密的文件系統(tǒng)又可以提供保存路徑 */ l2=strlen(input file

17、name for save: ); gotoxy(24+l2,10); scanf(%s,ds); man(sd,ds); fp2=fopen(e:ds.txt,rb); fread(buf1,sizeof(buf1),1,fp2); gotoxy(10,15); printf(%sn,buf1); getch(); printf(file haven jiemi,save now); getche(); break; int get_key() union REGS rg; rg.h.ah=0; int86(0x16,&rg,&rg); return rg.h.ah; getchar();v

18、oid box(int startx,int starty,int high,int width) /*屏幕的建立*/ int i; gotoxy(startx,starty); putch(0xda); for (i=startx+1;i width;i+) putch(0xc4); putch(0xbf); for(i=starty+1;i high+starty;i+) gotoxy(startx,i); putch(0xb3); gotoxy(width,i); putch(0xb3); gotoxy(startx,starty+high-1); putch(0xc0); gotoxy(startx+1,s

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論