Hello everyone,
I'm trying to implement a DES (Data Encryption Standard) algorithm to encrypt and decrypt files. It's all implemented regarding encoding and decoding.
DES algorithm reads 64 bits from file each time and encode them (the process is repeat till the end of file) to the new encrypted file. The decoding process is the opposite but that doesn't matter for this problem.
My problem is the algorithm is all implemented treating bits (0's and 1's) as strings (it's easier I guess). I want to known how can I read, inside a loop, 8bytes (64bits) from file each time and convert them to a string of bits. At the end I want to convert that 64 bits string back to bytes to be able to write them to the encrypted file.
Example code:
while (!EOF) {
String my64bits = read64BitsFromFile(file.bin);
encodeBitsString(my64Bits); // This is already done
writeBitsStringToFile(my64Bits);
}
So anyone can give me an hint on how to read bytes to string (only 0's and 1's) and write them back as bytes? And do it till the EOF?
Thanks in advanced! Cheers