❶ c語言(文件的移位與加密解密)
這道題,並不難,只是樓主,沒有說清,是就字母移位嗎?
但是看你的例子,有不全是。
程序如下:
#include <stdio.h>
#include <stdlib.h>
FILE *source;//源文件
FILE *destination;//目標文件
int key;//密鑰
char file[100];//文件名
void encryption()//加密
{
char ch;
printf("請輸入要加密的文件名\n");
scanf("%s",file);
if((source=fopen(file,"r"))==NULL)
{
printf("無法打開文件!\n");
exit(0);
}
printf("請輸入加密後的文件名\n");
scanf("%s",file);
if((destination=fopen(file,"w"))==NULL)
{
printf("無法創建文件!\n");
exit(0);
}
printf("請輸入密鑰\n");
scanf("%d",&key);
ch=fgetc(source);
while(ch!=EOF)
{
if(ch=='\n')
{
fputc(ch,destination);
ch=fgetc(source);
continue;
}
ch+=key;
fputc(ch,destination);
ch=fgetc(source);
}
fclose(source);
fclose(destination);
}
void decrypt()//解密
{
char ch;
printf("請輸入要解密的文件名\n");
scanf("%s",file);
if((source=fopen(file,"r"))==NULL)
{
printf("無法打開文件!\n");
exit(0);
}
printf("請輸入加密後的文件名\n");
scanf("%s",file);
if((destination=fopen(file,"w"))==NULL)
{
printf("無法創建文件!\n");
exit(0);
}
printf("請輸入密鑰\n");
scanf("%d",&key);
ch=fgetc(source);
while(ch!=EOF)
{
if(ch=='\n')
{
fputc(ch,destination);
ch=fgetc(source);
continue;
}
ch-=key;
fputc(ch,destination);
ch=fgetc(source);
}
fclose(source);
fclose(destination);
}
int main()//主函數提供菜單
{
int choice=0;
printf("******************\n");
printf("1 文件加密\n");
printf("2 文件解密\n");
printf("3 退出\n");
printf("******************\n");
printf("請輸入1 2 3選擇操作\n");
scanf("%d",&choice);
switch(choice)
{
case 1:encryption();break;
case 2:decrypt();break;
case 3:break;
}
return 0;
}
❷ C語言設計一個簡單的加密解密程序
C語言設計一個簡單的加密解密程序如下:
加密程序代碼:
#include<stdio.h>
main()
{
char c,filename[20];
FILE *fp1,*fp2;
printf("請輸入待加密的文件名:\n");
scanf("%s",filename);
fp1=fopen(filename,"r");
fp2=fopen("miwen.txt","w");
do
{
c=fgetc(fp1);
if(c>=32&&c<=126)
{
c=c-32;
c=126-c;
}
if(c!=-1)
fprintf(fp2,"%c",c);
}
while(c!=-1);
}
解密程序代碼:
#include<stdio.h>
#include<string.h>
main()
{
char c,filename[20];
char yanzhengma[20];
FILE *fp1,*fp2;
printf("請輸入待解密文件名:\n");
scanf("%s",filename);
printf("請輸入驗證碼:\n");
scanf("%s",yanzhengma);
if(strcmp(yanzhengma,"shan")==0)
{
fp1=fopen(filename,"r");
fp2=fopen("yuanwen.txt","w");
do
{
c=fgetc(fp1);
if(c>=32&&c<=126)
{
c=126-c;
c=32+c;
}
if(c!=-1)
fprintf(fp2,"%c",c);
}
while(c!=-1);
}
else
{
printf("驗證碼錯誤!請重新輸入:\n");
scanf("%s",filename);
}
}
❸ 如何用C語言對文件進行加密和解密急求......................
文件分為文本文件和二進制文件。加密方法也略有不同。
1、文本文件
加密的主要是文本的內容,最簡單的方法就是修改文檔的內容,比如1.txt中的文件內容:
abcd
只要給每一個字元+1,就可以實現加密。文件內容即會變為
bcde
2、二進制文件加密
二進制文件加密也就是對應用程序加密,需要理解可執行文件格式,比如Windows平台的Exe文件它是PE結構,Linux上的可執行文件是ELF結構,要對這樣的程序進行加密,實際上是開發一種叫做「殼」的程序,這種程序的開發,需要將扎實的底層基礎,同時也需要對軟體加密解密有細致的理解,比如流行的vmprotect、z殼以及早些年的upx殼、aspack等等。
3、無論哪種加密都牽涉到文件操作的問題,使用C語言進行文件操作時,極少使用C標准庫中的I/O函數,大多數使用操作系統提供的內存文件映射相關的API函數,有興趣,可以搜索相關的資料。
❹ word文檔不能修改如何解密
Word
Ctrl+S 保存
Ctrl+W 關閉程序
Ctrl+N 新建
Ctrl+O 打開
Ctrl+Z 撤銷
Ctrl+F 查找
Ctrl+X 剪切
Ctrl+C 復制
Ctrl+V 粘貼
Ctrl+A 全選
Ctrl+[ 縮小文字
Ctrl+] 放大文字
Ctrl+B 粗體
Ctrl+I 斜體
Ctrl+U 下劃線
Ctrl+Shift 輸入法切換
Ctrl+空格 中英文切換
Ctrl+回車 QQ號中發送信息
Ctrl+Home 游標快速移到文件頭
Ctrl+End 游標快速移到文件尾
Ctrl+Esc 顯示開始菜單
Ctrl+Shift+< 快速縮小文字
Ctrl+Shift+> 快速放大文字
Ctrl+F5 在IE中強行刷新
Ctrl+拖動文件 復制文件
Ctrl+Backspace 啟動\關閉輸入法
拖動文件時按住Ctrl+Shift 創建快捷方式
Alt+空格+C 關閉窗口
Alt+空格+N 最小化當前窗口
Alt+空格+R 恢復最小化窗口
Alt+空格+X 最大化當前窗口
Alt+空格+M 移動窗口
Alt+空格+S 改變窗口大小
Alt+Tab 兩個程序交換
Alt+255 QQ號中輸入無名人
Alt+F 打開文件菜單
Alt+V 打開視圖菜單
Alt+E 打開編輯菜單
Alt+I 打開插入菜單
Alt+O 打開格式菜單
Alt+T 打開工具菜單
Alt+A 打開表格菜單
Alt+W 打開窗口菜單
Alt+H 打開幫助菜單
Alt+回車 查看文件屬性
Alt+雙擊文件 查看文件屬性
Alt+X 關閉C語言
Shift快捷鍵
Shift+空格 半\全形切換
Shift + Delete 永久刪除所選項,而不將它放到「回收站」中。
拖動某一項時按 CTRL 復制所選項。
拖動某一項時按 CTRL + SHIFT 創建所選項目的快捷鍵。
WORD全套快捷鍵小技巧
CTRL+O 打開
CTRL+P 列印
CTRL+A 全選
CTRL+[/] 對文字進行大小設置(在選中目標情況下)
CTRL+D 字體設置(在選中目標情況下)
CTRL+G/H 查找/替換;
CTRL+N 全文刪除;
CTRL+M 左邊距(在選中目標情況下);
CTRL+U 繪制下劃線(在選中目標情況下);
CTRL+B 加粗文字(在選中目標情況下);
CTRL+I 傾斜文字(在選中目標情況下);
CTRL+Q 兩邊對齊(無首行縮進),(在選中目標情況下)或將游標放置目標文 字的段尾,亦可操作
CTRL+J 兩端對齊(操作同上)
CTRL+E 居中(操作同上)
CTRL+R 右對齊(操作同上)
CTRL+K 插入超鏈接
CTRL+T/Y 可進行首行縮進(將游標移到需做此操作的段尾,或將此段選中進行操作
Ctrl+A(或Ctrl+小鍵盤上數字5):選中全文。
Ctrl+B:給選中的文字加粗(再按一次,取消加粗)。
Ctrl+C:將選中的文字復制到剪貼板中。
Ctrl+D:打開「字體」對話框,快速完成字體的各種設置。
Ctrl+E:使游標所在行的文本居中。
Ctrl+F:打開「查找與替換」對話框,並定位在「查找」標簽上。
Ctrl+G:打開「查找與替換」對話框,並定位在「定位」標簽上。
Ctrl+H:打開「查找與替換」對話框,並定位在「替換」標簽上。
Ctrl+I:使選中的文字傾斜(再按一次,取消傾斜)。
Ctrl+K:打開「插入超鏈接」對話框。
Ctrl+Shift+L:給游標所在行的文本加上「項目符號」。
Ctrl+M:同時增加首行和懸掛縮進。
Ctrl+Shift+M:同時減少首行和懸掛縮進。
Ctrl+N:新建一個空文檔。
Ctrl+O(或Ctrl+F12):打開「打開」對話框。
Ctrl+P(或Ctrl+Shift+F12):打開「列印」對話框。
Ctrl+R:使游標所在行的文本右對齊。
Ctrl+S:為新文檔打開「另保存為」對話框,或對當前文檔進行保存。
Ctrl+T:增加首行縮進。
Ctrl+Shift+T:減少首行縮進。
Ctrl+U:給選中的文字加上下劃線(再按一次,去年下劃線)。
Ctrl+V:將剪貼板中的文本或圖片粘貼到游標處。若剪貼板中有多個內容,則將 最後一條內容粘貼到游標處。
Ctrl+X:將選中的文字剪切到剪貼板中。
Ctrl+Z:撤銷剛才進行的操作(可以多次使用)。
Ctrl+0:將選中的文本每段前增加12磅的間距。
Ctrl+1:若選中的文本行距不是「單倍行距」,則將其快速設置為「單倍行距」。
Ctrl+2:將選中的文本行距設置為「兩倍行距」。
Ctrl+5:將選中的文本行距設置為「1.5倍行距」。
Ctrl+F2:快速執行「列印預覽」功能。
Ctrl+F4:關閉當前文檔。
Ctrl+F5:使窗口還原到最大化之前的狀態。
Ctrl+Shift+F5:打開「書簽」對話框。
Ctrl+Shift+F8:激活列選擇功能,即通常所說的選擇豎塊文本(再按一次或按ESC鍵,取消該功能)。
Ctrl+F9:在游標處插入一域記號「{}」(注意:直接輸入的一對大括弧不能作為域記號)。
Ctrl+F5:使窗口還原到最大化之前的狀態(再按一次,就會使窗口再次最大化)。
Ctrl+Deltet:刪除游標後面的一個英文單詞或一個中文詞語(可反復使用)。
Ctrl+退格鍵:刪除游標前面的一個英文單詞或一個中文詞語(可反復使用)。
Ctrl+Enter:將游標後面的內容快速移到下一頁。
Ctrl+End:快速將游標移到文末。
Ctrl+Home(或Ctrl+Page Up):快速將游標移到文首。
Ctrl+Insert+Insert(即按兩下Insert鍵):快速打開或更改「任務窗格」到「剪貼板」狀態。
Ctrl+~:打開中文輸入法的「在線造詞」功能。
Ctrl++:快速切換到下標輸入狀態(再按一次恢復到正常狀態)。
Ctrl+Shift++:快速切換到上標輸入狀態(再按一次恢復到正常狀態)。
Ctrl+→:按英文單詞或中文詞語的間隔向後移動游標。
Ctrl+←:按英文單詞或中文詞語的間隔向前移動游標。
Ctrl+J:文本兩端對齊
Ctrl+L:文本左對齊
Ctrl+Q:段落重置
Ctrl+W:關閉當前文檔
Ctrl+Y:重復上一操作(部分操作不適用-
winkey+d :
這是高手最常用的第一快捷組合鍵。這個快捷鍵組合可以將桌面上的所有窗口瞬間最小化,無論是聊天的窗口還是游戲的窗口……只要再次按下這個組合鍵,剛才的所有窗口都回來了,而且激活的也正是你最小化之前在使用的窗口!
-
這個就是winkey
winkey+f :
不用再去移動滑鼠點「開始→搜索→文件和文件夾」了,在任何狀態下,只要一按winkey+f就會彈出搜索窗口。
希望對你有所幫助
❺ 高分求解c語言的簡單文件加解密
用C語言實現MD5演算法用C語言實現MD5演算法,這個夠復雜。。。
""用C語言實現MD5演算法.
1)global.h 頭文件
#ifndef PROTOTYPES
#define PROTOTYPES 0
#endif
/* POINTER defines a generic pointer type */
typedef unsigned char *POINTER;
/* UINT4 defines a four byte word */
typedef unsigned long int UINT4;
/* PROTO_LIST is defined depending on how PROTOTYPES is defined
above.If using PROTOTYPES, then PROTO_LIST returns the list, otherwise
it returns an empty list. */
#if PROTOTYPES
#define PROTO_LIST(list) list
#else
#define PROTO_LIST(list) ()
#endif
2)md5.h 頭文件
/* MD5 context. */
typedef struct {
UINT4 state[4]; /* state (ABCD) */
UINT4 count[2]; /* number of bits, molo 2^64 (lsb first) */
unsigned char buffer[64]; /* input buffer */
} MD5_CTX;
void MD5Init PROTO_LIST ((MD5_CTX *));
void MD5Update PROTO_LIST
((MD5_CTX *, unsigned char *, unsigned int));
void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
3)md5c.c 演算法的核心部分
/* 參考 RSA Data Security, Inc., MD5 message-digest algorithm 的C源程
序
*/
#include "global.h"
#include "md5.h"
/* MD5的主循環的輪主要操作為a=b+((a+f(b,c,d)+M+t)<<值如下:
*/
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23
#define S41 6
#define S42 10
#define S43 15
#define S44 21
/*函數調用說明*/
static void MD5Transform PROTO_LIST ((UINT4 [4], unsigned char [64]));
static void Encode PROTO_LIST
((unsigned char *, UINT4 *, unsigned int));
static void Decode PROTO_LIST
((UINT4 *, unsigned char *, unsigned int));
static void MD5_memcpy PROTO_LIST ((POINTER, POINTER, unsigned
int));
static void MD5_memset PROTO_LIST ((POINTER, int, unsigned int));
static unsigned char PADDING[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
/* F, G, H and I 是MD5的基本函數.
*/
#define F(x, y, z) (((x) & (y)) | ((~x) & (z)))
#define G(x, y, z) (((x) & (z)) | ((y) & (~z)))
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define I(x, y, z) ((y) ^ ((x) | (~z)))
/* ROTATE_LEFT將 x 循環左移n bits. */
#define ROTATE_LEFT(x, n) (((x) <> (32-(n))))
/* FF, GG, HH, and II 代表1,2,3,4輪計算,先宏定義以便於後面引用.
*/
#define FF(a, b, c, d, x, s, ac) { \
(a) += F ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define GG(a, b, c, d, x, s, ac) { \
(a) += G ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define HH(a, b, c, d, x, s, ac) { \
(a) += H ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
#define II(a, b, c, d, x, s, ac) { \
(a) += I ((b), (c), (d)) + (x) + (UINT4)(ac); \
(a) = ROTATE_LEFT ((a), (s)); \
(a) += (b); \
}
/* MD5 的初始化, MD5 操作的開始. */
void MD5Init (context)
MD5_CTX *context; /* context */
{
context->count[0] = context->count[1] = 0;
/* 給出4個32比特的初始向量.*/
context->state[0] = 0x67452301;
context->state[1] = 0xefcdab89;
context->state[2] = 0x98badcfe;
context->state[3] = 0x10325476;
}
/* MD5 塊更新操作.不斷地對消息塊進行MD5 消息-摘要操作,並更新
context.
*/
void MD5Update (context, input, inputLen)
MD5_CTX *context; /* context */
unsigned char *input; /* input block */
unsigned int inputLen; /* length of input block */
{
unsigned int i, index, partLen;
/* Compute number of bytes mod 64 */
index = (unsigned int)((context->count[0] >> 3) & 0x3F);
/* Update number of bits */
if ((context->count[0] += ((UINT4)inputLen << 3))
< ((UINT4)inputLen context->count[1] += ((UINT4)inputLen >> 29);
partLen = 64 - index;
/* Transform as many times as possible.
*/
if (inputLen >= partLen) {
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)input, partLen);
MD5Transform (context->state, context->buffer);
for (i = partLen; i + 63 state, &input);
index = 0;
}
else
i = 0;
/* Buffer remaining input */
MD5_memcpy
((POINTER)&context->buffer[index], (POINTER)&input,
inputLen-i);
}
/* MD5 的結束操作. 輸出128比特的散列值並對context歸零.
*/
void MD5Final (digest, context)
unsigned char digest[16]; /* message digest */
MD5_CTX *context; /*
context */
{
unsigned char bits[8];
unsigned int index, padLen;
/* Save number of bits */
Encode (bits, context->count, 8);
/* Pad out to 56 mod 64.
*/
index = (unsigned int)((context->count[0] >> 3) & 0x3f);
padLen = (index state, 16);
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)context, 0, sizeof (*context));
}
/* 對一個消息塊的16個子塊進行MD5 基本計算.
*/
static void MD5Transform (state, block)
UINT4 state[4];
unsigned char block[64];
{
UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16];
Decode (x, block, 64);
/* Round 1 */
FF (a, b, c, d, x[ 0], S11, 0xd76aa478); /* 1 */
FF (d, a, b, c, x[ 1], S12, 0xe8c7b756); /* 2 */
FF (c, d, a, b, x[ 2], S13, 0x242070db); /* 3 */
FF (b, c, d, a, x[ 3], S14, 0xc1bdceee); /* 4 */
FF (a, b, c, d, x[ 4], S11, 0xf57c0faf); /* 5 */
FF (d, a, b, c, x[ 5], S12, 0x4787c62a); /* 6 */
FF (c, d, a, b, x[ 6], S13, 0xa8304613); /* 7 */
FF (b, c, d, a, x[ 7], S14, 0xfd469501); /* 8 */
FF (a, b, c, d, x[ 8], S11, 0x698098d8); /* 9 */
FF (d, a, b, c, x[ 9], S12, 0x8b44f7af); /* 10 */
FF (c, d, a, b, x[10], S13, 0xffff5bb1); /* 11 */
FF (b, c, d, a, x[11], S14, 0x895cd7be); /* 12 */
FF (a, b, c, d, x[12], S11, 0x6b901122); /* 13 */
FF (d, a, b, c, x[13], S12, 0xfd987193); /* 14 */
FF (c, d, a, b, x[14], S13, 0xa679438e); /* 15 */
FF (b, c, d, a, x[15], S14, 0x49b40821); /* 16 */
/* Round 2 */
GG (a, b, c, d, x[ 1], S21, 0xf61e2562); /* 17 */
GG (d, a, b, c, x[ 6], S22, 0xc040b340); /* 18 */
GG (c, d, a, b, x[11], S23, 0x265e5a51); /* 19 */
GG (b, c, d, a, x[ 0], S24, 0xe9b6c7aa); /* 20 */
GG (a, b, c, d, x[ 5], S21, 0xd62f105d); /* 21 */
GG (d, a, b, c, x[10], S22, 0x2441453); /* 22 */
GG (c, d, a, b, x[15], S23, 0xd8a1e681); /* 23 */
GG (b, c, d, a, x[ 4], S24, 0xe7d3fbc8); /* 24 */
GG (a, b, c, d, x[ 9], S21, 0x21e1cde6); /* 25 */
GG (d, a, b, c, x[14], S22, 0xc33707d6); /* 26 */
GG (c, d, a, b, x[ 3], S23, 0xf4d50d87); /* 27 */
GG (b, c, d, a, x[ 8], S24, 0x455a14ed); /* 28 */
GG (a, b, c, d, x[13], S21, 0xa9e3e905); /* 29 */
GG (d, a, b, c, x[ 2], S22, 0xfcefa3f8); /* 30 */
GG (c, d, a, b, x[ 7], S23, 0x676f02d9); /* 31 */
GG (b, c, d, a, x[12], S24, 0x8d2a4c8a); /* 32 */
/* Round 3 */
HH (a, b, c, d, x[ 5], S31, 0xfffa3942); /* 33 */
HH (d, a, b, c, x[ 8], S32, 0x8771f681); /* 34 */
HH (c, d, a, b, x[11], S33, 0x6d9d6122); /* 35 */
HH (b, c, d, a, x[14], S34, 0xfde5380c); /* 36 */
HH (a, b, c, d, x[ 1], S31, 0xa4beea44); /* 37 */
HH (d, a, b, c, x[ 4], S32, 0x4bdecfa9); /* 38 */
HH (c, d, a, b, x[ 7], S33, 0xf6bb4b60); /* 39 */
HH (b, c, d, a, x[10], S34, 0xbebfbc70); /* 40 */
HH (a, b, c, d, x[13], S31, 0x289b7ec6); /* 41 */
HH (d, a, b, c, x[ 0], S32, 0xeaa127fa); /* 42 */
HH (c, d, a, b, x[ 3], S33, 0xd4ef3085); /* 43 */
HH (b, c, d, a, x[ 6], S34, 0x4881d05); /* 44 */
HH (a, b, c, d, x[ 9], S31, 0xd9d4d039); /* 45 */
HH (d, a, b, c, x[12], S32, 0xe6db99e5); /* 46 */
HH (c, d, a, b, x[15], S33, 0x1fa27cf8); /* 47 */
HH (b, c, d, a, x[ 2], S34, 0xc4ac5665); /* 48 */
/* Round 4 */
II (a, b, c, d, x[ 0], S41, 0xf4292244); /* 49 */
II (d, a, b, c, x[ 7], S42, 0x432aff97); /* 50 */
II (c, d, a, b, x[14], S43, 0xab9423a7); /* 51 */
II (b, c, d, a, x[ 5], S44, 0xfc93a039); /* 52 */
II (a, b, c, d, x[12], S41, 0x655b59c3); /* 53 */
II (d, a, b, c, x[ 3], S42, 0x8f0ccc92); /* 54 */
II (c, d, a, b, x[10], S43, 0xffeff47d); /* 55 */
II (b, c, d, a, x[ 1], S44, 0x85845dd1); /* 56 */
II (a, b, c, d, x[ 8], S41, 0x6fa87e4f); /* 57 */
II (d, a, b, c, x[15], S42, 0xfe2ce6e0); /* 58 */
II (c, d, a, b, x[ 6], S43, 0xa3014314); /* 59 */
II (b, c, d, a, x[13], S44, 0x4e0811a1); /* 60 */
II (a, b, c, d, x[ 4], S41, 0xf7537e82); /* 61 */
II (d, a, b, c, x[11], S42, 0xbd3af235); /* 62 */
II (c, d, a, b, x[ 2], S43, 0x2ad7d2bb); /* 63 */
II (b, c, d, a, x[ 9], S44, 0xeb86d391); /* 64 */
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
/* Zeroize sensitive information.
*/
MD5_memset ((POINTER)x, 0, sizeof (x));
}
/* Encodes input (UINT4) into output (unsigned char). Assumes len is
a multiple of 4. */
static void Encode (output, input, len)
unsigned char *output;
UINT4 *input;
unsigned int len;
{ unsigned int i, j;
for (i = 0, j = 0; j > 8) & 0xff);
output[j+2] = (unsigned char)((input >> 16) & 0xff);
output[j+3] = (unsigned char)((input >> 24) & 0xff);
}
}
/* Decodes input (unsigned char) into output (UINT4). Assumes len is a
multiple of 4. */
static void Decode (output, input, len)
UINT4 *output;
unsigned char *input;
unsigned int len;
{
unsigned int i, j;
for (i = 0, j = 0; j < len; i++, j += 4)
output = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) |
(((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24);
}
/* Note: Replace "for loop" with standard memcpy if possible. */
static void MD5_memcpy (output, input, len)
POINTER output;
POINTER input;
unsigned int len;
{ unsigned int i;
for (i = 0; i < len; i++)
output = input;
}
/* Note: Replace "for loop" with standard memset if possible. */
static void MD5_memset (output, value, len)
POINTER output;
int value;
unsigned int len;
{ unsigned int i;
for (i = 0; i < len; i++)
((char *)output) = (char)value;
}
4)md5test.c 主測試程序
/* MD5測試程序 */
#include
#include
#include "global.h"
#include "md5.h"
/* Length of test block, number of test blocks. */
static void MDString PROTO_LIST ((char *));
static void MDFilter PROTO_LIST ((void));
static void MDPrint PROTO_LIST ((unsigned char [16]));
/* Prints a message digest in hexadecimal.(十六進制) */
static void MDPrint (digest)
unsigned char digest[16];
{
unsigned int i;
printf("\n");
for (i = 0; i < 16; i++)
printf ("%02x", digest);
}
/* Digests the standard input and prints the result. */
static void MDFilter ()
{
MD5_CTX context;
int len;
unsigned char buffer[16], digest[16];
MD5Init (&context);
while (len = fread (buffer, 1, 16, stdin))
MD5Update (&context, buffer, len);
MD5Final (digest, &context);
MDPrint (digest);
printf ("\n");
}
/* Digests a string and prints the result. */
static void MDString (string)
char *string;
{
MD5_CTX context;
unsigned char digest[16];
unsigned int len = strlen (string);
MD5Init (&context);
MD5Update (&context, string, len);
MD5Final (digest, &context);
printf ("%s = ", string);
MDPrint (digest);
printf ("\n");
}
void main ()
{
printf ("MD5演算法測試:\n");
printf ("原文=\n");
printf ("MD5消息摘要\n");
MDString ("\n趙濤");
MDString ("\n合肥電大站 學號:01230100015");
MDString
("\
123456789");
}
❻ 如何使用c語言對word進行加密
你可以讀取word文件,把他當作純文本讀取,然後取個非或者異或什麼的,寫入新文件,就當作加密了。
❼ C語言 文件加密解密
根據你的需要,修改了之前的代碼。
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<time.h>
constunsignedintMAX_KEY_LENGTH=1000;
intencode(charconst*datafile,charconst*keyfill);
intdecode(charconst*datafile,charconst*keyfile);
intloadKey(charconst*keyfile,int*keys,unsignedintsize);
intsaveKey(charconst*keyfile,int*keys,unsignedintsize);
intgenerateKey(int*keys,unsignedintsize);
intmain(intargc,charconst*argv[])
{
chardatafile[]="encrypted.txt";
charkeyfile[]="key.txt";
intretcode,choice,loop=1;
charch[5]={'