-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhypwrite.c
More file actions
48 lines (37 loc) · 1.03 KB
/
hypwrite.c
File metadata and controls
48 lines (37 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <stdio.h>
#include <string.h>
#include "c_des.h"
#include "utils.h"
int main (int argc, char** argv) {
FILE *infile = fopen(argv[1],"rb");
if (!infile) {
printf("USAGE: %s input_file\n",argv[0]);
return 1;
}
fclose(infile);
FILE *pass = fopen("pass","wb");
struct hyp_struct hyp;
char pwd[40], check[40];
puts("Insert a password (8 characters), leave blank for random:");
gets(pwd);
fflush(stdin);
puts("Insert a checkstring (8 characters), leave blank for random:");
gets(check);
fflush(stdin);
printf("\n\n%s\n%s\n",pwd,check);
if (strlen(pwd) < 8) {
rand_string(pwd, 8);
}
if (strlen(check) < 8) {
rand_string(check, 8);
}
strncpy(hyp.check, check, 8);
hyp.check[8] = '\0';
strncpy(hyp.pass_hint, pwd,4);
hyp.pass_hint[4] = '\0';
DesEncrypt(hyp.check, pwd, hyp.enc_check);
fwrite(&hyp, sizeof(struct hyp_struct), 1, pass);
encrypt_file(argv[1], pwd, "enc_win");
fclose(pass);
return 0;
}