/* ---------- */ /* najcrypt.c */ /* ---------- */ /* naji encryption/decryption functions */ /* this .c file is a part */ /* of libnaji version 0.6.1 */ /* libnaji is based on */ /* the original najitool */ /* both najitool and libnaji */ /* are public domain and are */ /* made by the same author */ /* please read license.txt */ /* made by NECDET COKYAZICI */ /* plans for version 2.0 maybe make it just read a defined file like input.txt to output.txt make the file bigger depending on the password size. do something else to the encrypted byte instead of bit flipping it such as changing certain bits instead depending on the password. scramble the data, split/join files? make an unlimited amount of encryption strength like 100000000 bits (hehe) and make it user definable */ #include "libnaji.h" #define MIN_PASS_LENGTH 5 void get_password(void); void wipe_pwd(void); void get_strength(void); void check_ps(void); void naji_enc(void); void naji_dec(void); void endnaji(int error_level); char choice; char letter; char *naji_data; char iname[256]; char oname[256]; char password[256]; char tmpusr[30]; int strength=128; int pwd_len=0; long ifilesize=0; void endnaji(int error_level) { najinclose(); najoutclose(); wipe_pwd(); exit(error_level); } void get_password(void) { printf("\nEnter password: "); safegets(password, 255); printf("\n"); pwd_len = strlen(password); if (pwd_len < MIN_PASS_LENGTH) { fprintf(stderr, "\nPassword must be at least %d characters in length. Exiting program.\n\n", MIN_PASS_LENGTH); endnaji(10); } } void wipe_pwd(void) { int i=0; for (i=0; i strength) { fprintf(stderr, "The digit %d in the password contains a character with a value larger than %d.\n", a, strength); fprintf(stderr, "This is currently unsupported in this version on %d Bit encryption mode.\n", (strength * 8)); fprintf(stderr, "Encryption failed. Exiting program.\n\n\n"); endnaji(11); } } void naji_enc(void) { int a=0; int i=0; printf("Encrypting...\n\n"); ifilesize = najinsize(); while (ifilesize != 0) { ifilesize--; letter = fgetc(naji_input); a++; if (a > pwd_len) a=0; for (i=0; i pwd_len) a=0; for (i=0; i