![]() |
|
#1
|
|||
|
|||
feof() troubleI'm having some trouble with my little encryption program. It compiles alright but gives me a "Illegal Operation" when I run it, right after I input a key.
CPP / C++ / C Code:
You may reconize the function encrypt() as the TEA encryption alogarithm, I didn't write it and doubt it's part of the problem. I'm using the Dev-C++ compiler on a windows pc, if that matters. Any help will be appreciated. |
|
#2
|
|||
|
|||
ElaborationI was using
CPP / C++ / C Code:
|
|
#4
|
|||
|
|||
fscanf()Quote:
Can I use... CPP / C++ / C Code:
but with fscanf() instead of fgets()? |
|
#5
|
|||
|
|||
|
Quote:
In addition to the problems with eof testing that Walt pointed out: 1. Your scanf is wrong: CPP / C++ / C Code:
Should be something like the following to keep things legal: CPP / C++ / C Code:
However, it won't give you a very useful encryption/decryption function for general files. What if the file does not consist of lines of ascii representations of unsigned long ints? 2. The TEA algorithm works on 64-bit blocks of data (Can be two 32-bit ints or eight 8-bit chars). The key is a 128-bits (four 32-bit ints or 16 8-bit chars). The function that you are using only works for the following: v is an array of two 32-bit ints k is an array of four 32-bit ints 3. You need to get two 32-bit ints into the key. You need to read the file a byte at a time (actually 8 bytes at a time, since the algorithm works on 64-bit blocks of data). You need to open the file in binary mode in order to be able to encrypt and decrypt and get the exact same file back again. You can pack the chars of the file into two 32-bit ints if you want to use your function (and take care of the case that the file length is not a multiple of eight). Regards, Dave |
|
#6
|
||||
|
||||
|
Quote:
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
Recent GIDBlog
Prepping for deployment by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Trouble with finding a vowel using recursion | SnackMan78 | CPP / C++ Forum | 3 | 12-May-2005 14:35 |
| Really amatuer to C++, trigonometry trouble | Sancho | C Programming Language | 2 | 13-Jan-2005 03:16 |
| C programming trouble | Newworld | C Programming Language | 8 | 12-Sep-2004 23:06 |
| Trouble with Windows XP | vsseym | Computer Software Forum - Windows | 29 | 12-Aug-2004 03:56 |
| Having trouble trying to format C: | Nickster64 | Computer Software Forum - Windows | 2 | 27-Jul-2004 07:31 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The