?? 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";
/* 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 + -