|
I have a "user" type class with personal info in it which I wish to protect. I will use the Blowfish algorithm and I have two functions encrypt() and decrypt(). In my user class I used to serialize it to and from disk in plain text format using CArchive. What I can do is for each CString member of my user class I can encrypt each member before I serialize it or decrypt each member after I deserialize it.
I just want some opinion on what is the best way to do this. In some ways I think encrypting/decrypting each member (there are many members in the class) is not the best way. I wondered if I should encrypt/decrypt in one go in other words, when writing the file, I should write as plain text, then I should encrypt, or could I modify CArchive to do the encryption in a more logical manner?
Can anyone tell me how best to go about this because I want to not have lots of repetitive code to do the encryption and decryption.
|
|
|
|
|
I encrypt in memory then write to disk becuz if you write data to disk first then encrypt it, deleting your old file (unless you shred it first or encrypt over top original) it's then possible to undelete your original un-encrypted file. So I always encrypt in-memory before writting to disk.
Cheers
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Good point
I have now written my encryption code into my user class where I now think it belongs. I just pass my key to the user class and let that do the worrying about encryption.
|
|
|
|
|
The application that I am working on has a view with base class CListView. When I click on an item in the list, I change the state mask.
i.e.
lvi.state = INDEXTOSTATEIMAGEMASK(n);
Then, I update the list.
I would like to scroll to the item in the list which I have just changed. I have tried GetScrollInfo and SetScrollInfo. This moves the scroll bar to the specified position but the list view does not scroll (remains at top).
How do I scroll the view with the scrollbar?
Any advise which can help me understand this method is greatly appreciated.
|
|
|
|
|
Incredibly, after several evenings bashing my head on this problem, I found the answer directly after submitting my question. I have found that I only needed to use the method EnsureVisible.
Thanks to anyone who took time to read my dumb question. Any further advise is certainly welcome.
|
|
|
|
|
I do this same thing all the time
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
What is the fasted way to swap bytes in a ushort/ulong?
For example:
0x1234 -> 0x3412
0x12345678 -> 0x78563412
unsigned short short_exch(const unsigned short a)
{
return (a << 8) + (a >> 8);
};
unsigned long long_exch(unsigned long a)
{
unsigned long t = a&0xff;
a >>= 8;
t <<= 8;
t += a&0xff;
a >>= 8;
t <<= 8;
t += a&0xff;
a >>= 8;
t <<= 8;
return t + a;
};
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
Try a union :
<br />
typedef union<br />
{<br />
ULONG itemlong;<br />
UCHAR itemchar[4];<br />
} UnionLong;<br />
then you can swap the bytes through a temporary variable.
a two cent stamp short of going postal.
|
|
|
|
|
Didn't thought of a union
But even swapping with the xor trick I'm not sure how the compiler optimization would be. I guess looking at the asm code would make the final judgement.
Thanks.
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
unsigned long Swap(unsigned long value)
{
return ((value & 0xFF000000) >> 24) |
(value & 0x00FF0000) >> 8) |
(value & 0x0000FF00) << 8) |
(value & 0x000000FF) << 24);
}
Software Zen: delete this;
|
|
|
|
|
|
You're welcome. If you make the function inline , the compiler will compile it in place without the function call overhead (I forgot to do that).
Software Zen: delete this;
|
|
|
|
|
Of course inline!
Actually you can remove the masking for the 24 bit shifts. For the inner two bytes I don't see an improvement.
Thanks Gary for the follow up
Jürgen Eidt
http://cpicture.de/en
|
|
|
|
|
I need help in .cpp and .h implementation code for the 8 bit binary addition.
The program has to handle additions of both positive and negative binary strings with the following assumptions:
The first string is stored using two's complement and the second using 8-bit bias notation. The result should be a bit string in two's complement (including a decimal interpretation of the result). I even have to keep track of overflow condition.
It would be great if you can send me the code.
|
|
|
|
|
I think you would probably learn much more if you were to do your own homework than if someone else were to do it for you.
a two cent stamp short of going postal.
|
|
|
|
|
Hello,
I have not done MFC programming for quite awhile and am now undertaking a (sort of) relearning process.
Could someone tell me if I can implement a certain process in InitInstance (derived from CWinThread) without freezing the OS, i.e. a drive parser which looks for certain files to analyse & update.
Also, if you are in possession of a good knowledge about Threads (specifically CWinThread) would you mind telling me a bit about how it works in a general way?
Thank you for taking the time.
David
dNimrod#X
________________________
|
|
|
|
|
dNimrod#X wrote:
Could someone tell me if I can implement a certain process in InitInstance (derived from CWinThread) without freezing the OS, i.e. a drive parser which looks for certain files to analyse & update.
I guess you can. As long as you provide a way to inform your application's user about what the hell is happening i.e. why is it taking too long. are you getting my point? (Ofcourse, I am talking about interactive applications)
Gurmeet S. Kochar
If you believe in God, it's because of the Devil
|
|
|
|
|
Gurmeet S. Kochar wrote:
I guess you can. As long as you provide a way to inform your application's user about what the hell is happening i.e. why is it taking too long. are you getting my point? (Ofcourse, I am talking about interactive applications)
Yes I understand your point but what I am not sure about is if the dialog box's controls will still be accessible while the disk drive parsing is running. I mean, the question now is whether or not the dialog box will not freeze (if the message proc will still handle messages from the dialog box) ?
Ravi Bhavnani wrote:
Yes. But you will probably want to create the file search and analysis as a separate thread.
Do I really have to?
Thanks a lot for your replies and for taking the time.
dNimrod#X
________________________
|
|
|
|
|
Yes. But you will probably want to create the file search and analysis as a separate thread.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
i have two questions:
1) how do i go about creating a gui for a dos (not dos-mode) application? ie. what program do i use to creat this?
2) if i don't want to make a gui then what do i need to make a command based application in dos? and are .exe and .com the same thing?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
1) DOS has not a gui support, you need a third party library like Borland's Turbo Vision (text mode windows) or other.
2) All reasonable programing tools (Turbo Pascal, C/C++) for dos can create command-line programs.
Pavel
Sonork 100.15206
|
|
|
|
|
i know dos doesn't have a gui support....so how do i make one? ex. i've seen some bios screens that have a gui.
i made a console app in c# but i guess it won't run in dos. can i make a console app in c++ .net or c++ 6.0?
thanks,
Rob Tomson
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
certainly ,you can make a console app in c++ 6.0.and you can make a gui like some bios screens .In visual c++ 6.0 you can't use windows classes like CWnd .
i'm software engineer
|
|
|
|
|
You might want to try these (somewhat dated) packages:Check out other links here[^]. Good luck!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi all,
In a dialog, is it possible to align a control with layout guidelines such that if the dialog is resized, the conrol is also resized accordingly?
Mark
|
|
|
|