|
What are you expecting to see? CryptBinaryToString() only understands BYTEs as input so whether
you input a char string or a byte buffer is irrelevant.
A byte has 256 values. That means that somehow CryptBinaryToString() must be able to represent
256 values with a limited set of ASCII characters.
Again, what do you want to see? Maybe that API isn't appropriate for your needs.
Mark
|
|
|
|
|
Dear Mark,
I basically want to convert each byte in the encrypted data into two hexidecimal characters. For example 'z' becomes 7A. However my encrypted data is not of fixed length so I'm not sure how do to this.
Also once I have the hexidecimal character encrypted data I also need to convert it back into the encrypted data. So that is the functionality I'm looking for.
So any suggestions.
Thanks.
vg
|
|
|
|
|
Ok, I'm with you. I think the CryptBinaryToString(() API was meant more for converting binary
into characters that can be used in HTML/XML/etc. Not necessarily to be human-readable.
The problem is that in the encrypted data there's no 'z'. There's just bytes.
You'll need to store the length somehow. An easy way is to reserve the first BYTE/WORD/DWORD
to hold the length of the following encrypted data.
With the length, you can loop through the encrypted bytes, converting each to hex and
appending to a string.
I'm not sure about converting it back to encrypted though. If you allow the user to make
changes then the data won't be able to be unencrypted later.
It doesn't make sense really anyway - how can a user understand encrypted data?
Mark
|
|
|
|
|
hi every one
i have a single document project that inheritored from CFormViwe
i add one Dialog with one Button ,and in OnCreate CMainFram Create one DialogBar.
if (!m_wndDlgBar.Create(this, IDD_DIALOGBAR,<br />
CBRS_LEFT|CBRS_TOOLTIPS|CBRS_FLYBY, IDD_DIALOGBAR))<br />
{<br />
TRACE0("Failed to create DlgBar\n");<br />
return -1;
}
Then create BN_CLICKED message in CMainframe.
my button work corectly.
now i create one class for mydialogBar and write my code in OnInitUpdate or OnDraw
But it can not be run.
Please Help Me.
|
|
|
|
|
samira samehforooghy wrote: now i create one class for mydialogBar
Which derives from ??
samira samehforooghy wrote: and write my code in OnInitUpdate or OnDraw
Why you want to write this code there ?
There will mulitple calls to above code.
|
|
|
|
|
hi
prasad_som wrote: Which derives from ??
CDialog
whats the mean of mulitple
With special thanks
|
|
|
|
|
I asked about dialog bar class. Does it derive from CDialogBar .
What about my second question asked previously.
|
|
|
|
|
how to access CMOS RAM?
can any body help me in this.
pavan
|
|
|
|
|
Hi
All
I want to read value in string table in resource dll in VC++ 6.0. I want to call value in string table in Dll to another application. If anybody have solution to this plz send me.
Thanks in advance.
Atool
|
|
|
|
|
M. Atul wrote: I want to read value in string table in resource dll in VC++ 6.0. I want to call value in string table in Dll to another application.
Use LoadLibrary and LoadString.
M. Atul wrote: If anybody have solution to this plz send me.
Read this[^] too. Point number 2.
|
|
|
|
|
Hi All!
When in a simple project, I add a control activeX in a dialogue box it work perfectly, however when i make the dialog box (containing the activeX) in a dll (MFC DLL), i get nothing (no dialog box and consequently no activeX). When i remove the activeX control, the dialog box can be displayed!
my question is so how to add a activex control in a dll?
Thank u in advance.
Nirmal
|
|
|
|
|
I think the problem lies with the resource file being used.. As the dialogue template is in your DLL, where as your main app searches the template in its own resources and consequently dont find anything .. Try using the dll's resources .. try using the FindResource(..) function and then creating the dialogue from the template returned by the function .. I hope it helps enjoy.
|
|
|
|
|
I would ask this question on the algorithms/maths board, but I feel it is more appropriate here.
Lets say I have 2 points, { X1,Y1 } and { X2,Y2 }, I want to calculate the rotation of #2 around #1 given a number of degrees. What is the fasted possible way to do this in C++?
Here is my method, which I find to be too slow.
X2 = X1 * cosf(rotate) - Y1 * sinf(rotate);<br />
Y2 = X1 * sinf(rotate) + Y1 * cosf(rotate);
|
|
|
|
|
You code calculates cosf() and sinf() twice - you could probably speed things up by almost 2 x by only calculating cosf(rotate) and sinf(rotate) once and assigning the values to local variables.
Hope this helps
Tony
|
|
|
|
|
As calculating cosines and sines is expensive, another optimization could be to just calculate them once and make a table for the values ( may in application startup ) this will considerably increase the speed . If you are rotating these values multiple times. A question you might ask is but the value for the angle could be infinte and hence the table size. The catch here is every angle's cosine/sine is equal to an angle b/w 0-180 (0-pie).. so pratically you need only a table of 180 entries .
I hope this help!
enjoy
|
|
|
|
|
Thats an excellent idea, thanks for that.
|
|
|
|
|
The pleasure is all mine :->
|
|
|
|
|
Nutkase is right, this method can dramatically improve performance but is only suitable if you can live with integer angle values (every degree) since these will be used directly as indexes into the look-up tables.
If you need finer resolution than 1 degree you could consider having table entries every 0.1 degree but you would need to scale the angles to ensure that you have integral values e.g. 15. degrees would be index 15 in the table.
Naturally the tables would be 10 times bigger i.e. 1800 entries (actually you could get a way with storing values for only 90 degrees
|
|
|
|
|
softwaremonkey wrote: only suitable if you can live with integer angle values (every degree)
Thats no problem in this instance.
The major problem I am having at the moment is when placing the rotation code inside a loop, where the point being rotated is constantly being refreshed.
Here is a slightly faster method I have tried to adapt.
FPOINT Rotate( float px, float py, float ox, float oy, int a )
{
float s = ( PI * a ) / 180;
FPOINT q = { px, py };
if ( px == ox && py == oy ) {
return q;
}
float r;
if ( px == ox ) {
if ( py > oy ) {
r = PI / 2;
} else {
r = - PI / 2;
}
} else {
if ( py == oy ) {
if ( px < ox ) {
r = PI;
} else {
r = 0;
}
} else {
if ( px < ox ) {
r = atan( (float)( py - oy ) / ( px - ox ) ) + PI;
} else {
r = atan( (float)( py - oy ) / ( px - ox ) );
}
}
}
float hyp = sqrt( (float)( (px - ox) * (px - ox) ) + ( ( py - oy ) * ( py - oy ) ) );
q.x = ( ox + cos(s+r) * hyp );
q.y = ( oy + sin(s+r) * hyp );
return q;
}
It's faster, but doesn't work correctly. I have 4 points denoted by the corners of a rectangle. I calc the center of the mass and pass it is as point 'o', then for each of the 4 points 'p' A calc their new positions. The resulting rectangle appears to rotate about the top-right corner ( which itself is traveling up and down a 45 degree line ). I can't for the life of me see where it is going wrong.
|
|
|
|
|
NM...
It was a stupid error in calculating the center of the mass.
|
|
|
|
|
hi,
what is the need for advapi32.lib??
|
|
|
|
|
mike dano wrote: what is the need for advapi32.lib??
For dynamically linking to advapi32.dll which contains registry related functions, service related operations and many more.
Just use dependency walker to find out what are the functions being exported by advapi32.dll
|
|
|
|
|
Hi,
I have some code that tries to get hold of a mutex using WaitForSingleObject and if it succeeds, it performs a sequence involving a delay using Sleep(). My question is, will the thread still own the mutex while it is sleeping or can other threads get hold of it? I DONT want other threads to be able to grab the mutex during the delay. The code is something like...
{
if(WaitForSingleObject(m_hDcpdMutex, DCPD_TIMEOUT) != WAIT_OBJECT_0)
{
return false;
}
m_pKeithley->ReadChannel(m_nCrackPDChan[i], &pOffVals[i]);
SetCurrent(1); // Turn current on
Sleep(m_nSettleTime); // Allow to settle
m_pKeithley->ReadChannel(m_nCrackPDChan[i], &pOnVals[i]);
SetCurrent(0); // Turn current off
ReleaseMutex(m_hDcpdMutex);
return true;
}
Any help/comments would be much appreciated!
Tony
|
|
|
|
|
softwaremonkey wrote: My question is, will the thread still own the mutex while it is sleeping or can other threads get hold of it? I DONT want other threads to be able to grab the mutex during the delay. The code is something like...
From the docs:
Only one thread can own a mutex at any given time. <code>The owning thread uses the
ReleaseMutex function to release its ownership.</code>
|
|
|
|
|
Hi,
I am trying to use some open source codes which is trying to include the <hash_map> header and it's not found in VC6. May I know if it is possible for me to download the missing header and source somewhere and use it in my project?
I saw a website as below:
http://www.cs.cmu.edu/afs/cs.cmu.edu/user/gchen/www/download/stl/download.html[^]
How can I use it? Thanks.
-- modified at 4:27 Monday 22nd January, 2007
|
|
|
|