summaryrefslogtreecommitdiff
path: root/decrypt.c
diff options
context:
space:
mode:
authorNathan Lasseter <nathan.je.lasseter@googlemail.com>2012-06-05 19:42:32 +0100
committerNathan Lasseter <nathan.je.lasseter@googlemail.com>2012-06-05 19:42:32 +0100
commit8330cef7c4e11024d66a3db37bb9b0f22429fbec (patch)
treedc35d63249f395312d0272d5258098b14e4c0fb1 /decrypt.c
parent8f3c51cc4cbc0fe456d1dc1bfcc666cfee78623b (diff)
SimpleCrypt 0.3 (copied in for historical reasons)
Diffstat (limited to 'decrypt.c')
-rw-r--r--decrypt.c43
1 files changed, 0 insertions, 43 deletions
diff --git a/decrypt.c b/decrypt.c
deleted file mode 100644
index b068bb9..0000000
--- a/decrypt.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <unistd.h>
-
-int main(int argc, char** argv) {
- /* We need a file to encrypt */
- if(argc==1) {
- fprintf(stderr, "Arguments fool!");
- return 1;
- }
- /* Now lets open that file */
- FILE* file = fopen(argv[1], "r");
- /* And a temporary file to hold the encrypted data */
- char tpath[255] = "/tmp/";
- strcat(tpath, argv[1]);
- FILE* temp = fopen(tpath, "w");
- /* Now we need the passphrase. Get it */
- printf("Enter Passphrase:\n");
- char passphrase[255];
- fgets(passphrase, 255, stdin);
- int passlen = strlen(passphrase) - 1;
- int c,j=0;
- /* Now we encrypt! */
- while((c=fgetc(file)) != EOF) {
- if(j==passlen) {
- fputc(c-passphrase[0], temp);
- j=1;
- } else {
- fputc(c-passphrase[j], temp);
- j++;
- }
- }
- /* Close the files */
- fflush(temp);
- fclose(temp);
- fclose(file);
- /* Move the file back */
- char cmd[255];
- sprintf(cmd, "%s %s %s", "/bin/mv", tpath, argv[1]);
- system(cmd);
- return 0;
-}