From 8f3c51cc4cbc0fe456d1dc1bfcc666cfee78623b Mon Sep 17 00:00:00 2001 From: Nathan Lasseter Date: Tue, 5 Jun 2012 19:42:14 +0100 Subject: SimpleCrypt 0.2 (copied in for historical reasons) --- Makefile | 18 +++++++++++++++--- decrypt.c | 41 ++++++++++++++++++++++++----------------- encrypt.c | 44 ++++++++++++++++++++++++++------------------ 3 files changed, 65 insertions(+), 38 deletions(-) diff --git a/Makefile b/Makefile index eaa7d67..df7fbd6 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,22 @@ -CFLAGS=-Wall -Wextra +CFLAGS=-Wall -Wextra -O3 all: make encrypt make decrypt encrypt: encrypt.c - gcc -o $@ $^ ${CFLAGS} + gcc ${CFLAGS} -o $@ $^ decrypt: decrypt.c - gcc -o $@ $^ ${CFLAGS} + gcc ${CFLAGS} -o $@ $^ + +install: + cp encrypt /usr/local/bin/encrypt + cp decrypt /usr/local/bin/decrypt + +uninstall: + rm /usr/local/bin/sc-encrypt + rm /usr/local/bin/sc-decrypt + +clean: + rm encrypt + rm decrypt diff --git a/decrypt.c b/decrypt.c index 3f84bca..b068bb9 100644 --- a/decrypt.c +++ b/decrypt.c @@ -1,36 +1,43 @@ #include #include #include +#include int main(int argc, char** argv) { - if(argc==0) { + /* 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"); - fseek(file, 0, SEEK_END); - int length = ftell(file); - fseek(file, 0, SEEK_SET); - char filearr[length]; - fread(filearr, length, 1, file); - fclose(file); + /* 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[81]; - fgets(passphrase, 81, stdin); + char passphrase[255]; + fgets(passphrase, 255, stdin); int passlen = strlen(passphrase) - 1; - int i=0,j=0; - for(i=0;i #include #include +#include int main(int argc, char** argv) { - if(argc==0) { + /* 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"); - fseek(file, 0, SEEK_END); - int length = ftell(file); - fseek(file, 0, SEEK_SET); - char filearr[length]; - fread(filearr, length, 1, file); - fclose(file); + /* 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[81]; - fgets(passphrase, 81, stdin); + char passphrase[255]; + fgets(passphrase, 255, stdin); int passlen = strlen(passphrase) - 1; - int i=0,j=0; - for(i=0;i