|
-
June 17th, 2002, 10:38 AM
#1
manipulation of files
HI to all
I want to open a encrypted file from disk, decrypt it, and use its contents, without saving it to the disk (i mean the decrypted file).
I do the Encryption and the decryption the problem is how can I use it without saving it to the disk??
I can resume the problem: I want to create a file use it but I don't want to save it??
can any one help?
thank you
khaldoun
-
June 17th, 2002, 10:46 AM
#2
I can resume the problem: I want to create a file use it but I don't want to save it??
The beginning is not clear. Do you want to open or to create a file?
Why speaking of a file if it does not exist at all on the disk? The, all you need is a data structure to hold you data. It might be as simple as a simple buffer, or more elaborated structures, arrays, ...
If you want to open a file from the disk but not save it. It is as simple: do not write in it, just read from it, and work on the data you read from it.
Then you can apply you encryption and decryption functions on your buffer or data structure.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
June 17th, 2002, 10:51 AM
#3
Thank you
my problem is that I use a decryption function who create a file to save the decrypted data to it.
and I use this file to construct an Image.
I want to bypass this procedure and directly create my image from the decrypted data.
thank you
-
June 17th, 2002, 11:21 AM
#4
I suppose that your decoding function reads one fragment of your file decode it and then write it to another file.
Instead of writing it to another file, you could write it to a buffer. When the decoding is complete, the buffer then contains your image.
Elrond
A chess genius is a human being who focuses vast, little-understood mental gifts and labors on an ultimately trivial human enterprise.
-- George Steiner
-
June 17th, 2002, 01:30 PM
#5
Maybe the stringstream class will help. It is similar
to what Elrond suggested, in that you use a buffer,
but you can also use various i/o functions to read/write
to the buffer. (it combines string and streams). Here
is a small sample :
Code:
#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::stringstream ss(std::ios::binary|std::ios::in|std::ios::out);
ss.put('a');
ss.put('b');
ss.put('c');
ss.put('d');
ss.seekg(0);
char c;
while (ss.get(c))
{
std::cout << c;
}
std::cout << std::endl;
std::cout << ss.str() << std::endl; // ss.str() is std::string
std::cout << ss.str().c_str() << std::endl; // ss.str().c_str() is C style string (read only)
return 0;
}
-
June 18th, 2002, 02:42 AM
#6
Thank you for your help
the problem is that I construct my Image using the file name.
I use visual C++ and the class CImage can be constructed using a file name or a IStream class. and the IStream class isn't like a normal buffer and I don' t know how to use it.
so I want to use a file name??
if I create the file, use it, and then delete it in the same function is there any possiblity that any one using my function has access to the file??
thank you
khaldoun
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|