diff options
author | Nathan Lasseter <nathan.je.lasseter@googlemail.com> | 2012-06-05 19:41:29 +0100 |
---|---|---|
committer | Nathan Lasseter <nathan.je.lasseter@googlemail.com> | 2012-06-05 19:41:29 +0100 |
commit | 3f9415f3c0ba8186cdf86a616f383a880e9d006e (patch) | |
tree | 52e255485978052544c6cae72fb4ea29b9dd147f /decrypt.c |
SimpleCrypt 0.1 (copied in for historical reasons)
Diffstat (limited to 'decrypt.c')
-rw-r--r-- | decrypt.c | 36 |
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; +} |