多线程程序设计------一个实例(SDES破解)

本文介绍了一个使用多线程技术破解SDES加密的实例。主线程创建新线程进行密钥穷举,通过PostThreadMessage进行线程间通信,主线程接收并处理传递的结构体参数及特定的MSG消息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#include"time.h"
#include"stdlib.h"
#include"stdio.h"
#include"S_DES.h"
#include"string.h"
#include"windows.h"
#include"iostream.h"

#define STRMAX 50
const WM_GET_MSG=WM_USER+1;//搜索成功的消息类型
const WM_FINISH_MSG=WM_USER+2;//搜索完毕的消息类型
DWORD MainThreadID;//主线程ID

typedef struct threadstruct//线程参数结构体
{
	int ID;
	int start;
	int end;
	char cipher[STRMAX];
}threadstruct;

int WriteToFile(char *filename,char *char_str,int str_len)//将密文写入文件
{
	int FileLength;
	FILE *SecretFile=fopen(filename,"w");
	if(SecretFile==NULL)
	{ 
        printf("文件打开失败!\n");
		return -1;
	}
	FileLength=fwrite(char_str,sizeof(char),str_len,SecretFile);
	if(FileLength<1)
    {
		printf("写入文件失败!\n");
		return FileLength;
	}
	fclose(SecretFile);
	return 1;
}

int ReadFromFile(char *filename,char *char_str,int *str_len)//从文件读取密文
{
	int FileLength;
	FILE *SecretFile=
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值