❶ 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]={'