summaryrefslogtreecommitdiff
path: root/decrypt.c
diff options
context:
space:
mode:
Diffstat (limited to 'decrypt.c')
-rw-r--r--decrypt.c36
1 files changed, 36 insertions, 0 deletions
diff --git a/decrypt.c b/decrypt.c
new file mode 100644
index 0000000..3f84bca
--- /dev/null
+++ b/decrypt.c
@@ -0,0 +1,36 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char** argv) {
+ if(argc==0) {
+ fprintf(stderr, "Arguments fool!");
+ return 1;
+ }
+ FILE* file = fopen(argv[1], "r");
+ fseek(file, 0, SEEK_END);
+ int length = ftell(file);
+ fseek(file, 0, SEEK_SET);
+ char filearr[length];
+ fread(filearr, length, 1, file);
+ fclose(file);
+ printf("Enter Passphrase:\n");
+ char passphrase[81];
+ fgets(passphrase, 81, stdin);
+ int passlen = strlen(passphrase) - 1;
+ int i=0,j=0;
+ for(i=0;i<length;i++) {
+ if(j==passlen) {
+ j=0;
+ i--;
+ } else {
+ filearr[i] -= passphrase[j];
+ j++;
+ }
+ }
+ file = fopen(argv[1], "w");
+ fwrite(filearr, 1, length, file);
+ fflush(file);
+ fclose(file);
+ return 0;
+}