📄 wjcdestest.cpp
字号:
// 3-Des test
#include "WjcDes.h"
#include "stdio.h"
#include "string.h"
#include "memory.h"
#include "iostream.h"
#include <string.h>
#include <stdio.h>
#define N 100
#include <time.h> //测试时间头文件
void main()
{
double start,finish;//定义开始结束
start=(double)clock();//开始计时
//read characters from the txt file;
FILE *stream;
// char string[] = "This is a test";
char msg[N];
/* open a file for update */
// stream = fopen("DUMMY.FIL", "w+");
stream = fopen("2.txt", "r+");
/* write a string into the file */
// fwrite(string, strlen(string), 1, stream);
/* seek to the start of the file */
fseek(stream, 0, SEEK_SET);
/* read a string from the file */
//fgets(msg, strlen(string)+1, stream);
fgets(msg, N, stream);
/* display the string */
//printf("%s", msg);
/* char key[]={0,2,0,0,9,3,5,1,9,8,0,0,9,1,7},buf[255];
char str[]="Welcome to My 3-DES Test! --WangJunchuan\n"
"Northeastern University (www.neu.edu.cn)\n"
"Email: blackdrn@sohu.com";
*/
// char str[]="xiaowei is the best in the world";
char key[]={0,2,0,0,9,3,5,1,9,8,0,0,9,1,7},buf[N];
char str[N];
for (int j=0;j<=N-1;j++)
{
str[j]=msg[j];
}
memset(buf, 0, sizeof(buf));
strcpy(buf, str);
puts("\nBefore encrypting");
puts(buf);
// Des_Go(buf, buf, sizeof(str), key, sizeof(key), ENCRYPT);
// puts("\nAfter encrypting");
// puts(buf);
Des_Go(buf, buf, sizeof(str), key, sizeof(key), DECRYPT);
puts("\nAfter decrypting");
puts(buf);
finish=(double)clock(); //结束时间
printf("%.4fms",(finish-start));//输出时间
/* open a file for update */
stream = fopen("1.txt", "w+");
/* write a string into the file */
fwrite(buf, strlen(buf), 1, stream);
/* seek to the start of the file */
fseek(stream, 0, SEEK_SET);
/* read a string from the file */
fgets(msg, strlen(buf)+1, stream);
/* display the string */
printf("%s", msg);
fclose(stream);
getchar();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -