|
|
You got to understand that compiling and linking are different things and steps in building a program.
I think you got to include the lib, I guess the "math.lib" in your project settings.
Greetings from Germany
|
|
|
|
|
KarstenK wrote: I think you got to include the lib, I guess the "math.lib" in your project settings.
Doubtful, since ut_asin() is his own function.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hello,
I am creating a challenge response application and in that making a call to encrypt a buffer that looks like
PBYTE pBufPtr
if(!Encrypt(hKey, 0, TRUE, 0,(BYTE *)pBufPtr, &dwCount, dwBufferLen))
In this case I want to take the encrypted data pBufPtr and display it as a string to the user. So any suggestions on how I can convert the pBufPtr into a decimal number or string that can be displayed to the user for typing purposes.
Also the decimal or string value obtained by converting the pBufPtr needs to be converted back into the encrypted data for the response side of the application.
So I need to convert encrypted data into string/decimal/BCD and take that string/decimal/BCD and convert it back into the encrypted data buffer.
So please let me know how is this possible. Thank you.
vg
|
|
|
|
|
Are you asking for a encryption/decription routine, or how to convert a byte pointer to something displayable ?
|
|
|
|
|
I am asking to convert the encrypted byte data to something displayable. The encrypted data looks like
"Œ[Ü‹¼| £](%Î݇X/2A9›Žf˜Qvdýýýý««««««««îþîþ"
so it has symbols such as ««««««« %
how do I convert the this binary data into something displayable so that it can be displayed on the screen for the user to read it.
The idea is to create a challenge by encrypting the data.
2) This encrypted data user reads it out from the a dialog in some displayable form(this part I need help on)
3) That converted encrypted data is converted back to its binary form and used to create the response.
vg
|
|
|
|
|
vgandhi wrote: In this case I want to take the encrypted data pBufPtr and display it as a string to the user. So any suggestions on how I can convert the pBufPtr into a decimal number or string that can be displayed to the user for typing purposes.
Also the decimal or string value obtained by converting the pBufPtr needs to be converted back into the encrypted data for the response side of the application
The simplest thing to do is to convert each byte of the encrypted data into two hexidecimal characters, so that a byte of the value of 'z' becomes the string of two characters: '7A' , and you can extend this to each byte of encrypted data. I.e 'ijk123' becomes '696A6B313233' .
If the encrypted data is of fixed length, for example, it will always be 10 characters of encrypted data, you can render it to hexidecimal and back again using functions like sprintf(...) and sscanf(...) .
::sprintf( "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
btaEncData[ 0 ], btaEncData[ 1 ], btaEncData[ 2 ], btaEncData[ 3 ],
btaEncData[ 4 ], btaEncData[ 5 ], btaEncData[ 6 ],
btaEncData[ 7 ], btaEncData[ 8 ], btaEncData[ 9 ] );
::sscanf( cpHexData, "%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X",
&btaEncData[ 0 ], &btaEncData[ 1 ], &btaEncData[ 2 ], &btaEncData[ 3 ],
&btaEncData[ 4 ], &btaEncData[ 5 ], &btaEncData[ 6 ],
&btaEncData[ 7 ], &btaEncData[ 8 ], &btaEncData[ 9 ] ); That is a simple example, and not the most optimal, but it should give you the general idea.
You can reduce the amount of data the user has to type by converting the encrypted data buffer into blocks of 32-bit values (DWORD s) or 64-bit values (hyper s), and using a function like ultoa(...) or _ui64toa(...) with a higher radix to reduce number of characters but use a wider range of them, and use the corresponding ato*(...) functions to convert them back.
ultoa( 0xFFFFFFFF, caBuffer, 10 );
ultoa( 0xFFFFFFFF, caBuffer, 16 );
ultoa( 0xFFFFFFFF, caBuffer, 36 ); Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Dear James,
Say I use the following
ultoa( 0xFFFFFFFF, caBuffer, 10 ); and the value I get is "4294967295"
Now how would I conver the 429496... number back into the original caBuffer form after making the above call.
Please let me know.
Thanks
vg
|
|
|
|
|
vgandhi wrote: Now how would I conver the 429496... number back into the original caBuffer form after making the above call.
As i said, the ato*(...) functions - for example, if you use ultoa(...) to convert to string (ltoa == long to ascii/ANSI), you can use the atol(...) to get it back to a number (atol == ASCII/ANSI to long).
If you look up those functions, you will see that there is no atoul(...) function - but you will find the strto*(...) functions. In this example, strotul(...) will convert it back.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Hey guys,
I am using this code to convert the data into string
CryptBinaryToString((BYTE *)pBufPtr,len,1,msg2,&lul_buflen);
The msg2 looks like
"KBeMW9yLvHwMow5dKCXO3ddKLzIGQTmbtNVmmFF2FmT9/f39q6urq6urq6vu/u7+"
and I am using the following functions to convert the string to long so that I can reduce the size to be displayed on the string
char *p;
long l = strtol(msg2, &p, 10);
long temp1 = atoi(msg2);
But both of them return 0 as the value.
Please help. Thanks.
vg
|
|
|
|
|
Dear James,
In the message above you said we can reduce the buffer by using the function ultoa. But my question is I have to first convert the buffer into ulong and then use the function ultoa. So how do I convert the buffer to ulong because the function ultoa takes in a ulong as its first parameter. So please let me know.
Thanks.
vg
|
|
|
|
|
The way to do that is to pad the data buffer (if required) to a 4-byte boundary, and then take 4 byte "chunks" of them, cast the address of the chunk to an unsigned long* (or DWORD* ), and then dereference the pointer to get a DWORD value to convert.
But since you are already converting the binary data to a string (as shown in a later example you posted), you will gain little if nothing by using my suggestion - your converting the binary data to a Base64 encoded string actually expands it (each three binary bytes becomes 4 ASCII characters using Base64 encoding).
You may reduce the raw binary data a bit, but the worst case you can get using my idea is 7 alphanumeric digits per 4 binary bytes, as opposed to hexidecimal's which is 8 alphanumeric per 4 bytes of raw data.
You can see an example of this here:
TCHAR caBuffer[ 32 + 1 ];
BYTE btaBinary[] = { 0x00, 0x04, 0xE4, 0xF0 };
BYTE btaBinary2[] = { 'A', 'b', '1', '2' };
BYTE btaBinary3[] = { 0xFF, 0xFF, 0xFF, 0xFF };
::_ultot( *(DWORD*)btaBinary, caBuffer, 36 );
::_ultot( *(DWORD*)btaBinary2, caBuffer, 36 );
::_ultot( *(DWORD*)btaBinary3, caBuffer, 36 );
- And by reading the contents of caBuffer after each call to ::_ultot(...)
If you can somehow compress the data, or reduce the encryption such that the length of the cyphertext is closer to the length of the plaintext, that will also go a long way.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Dear James,
In your above example how would I convert the encrypted data if it is not of fixed length using your solution above.
Also once everything is converted to hexidecimal now how would I convert that back into the encrypted data again?
Please let me know.
Thanks.
vg
|
|
|
|
|
You would pad the data out to the DWORD boundary as required. Using a function like ::strtoul(...) would convert the data back into DWORDs, from which you could get your original data from.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
If your app will be run on XP+, you can use CryptBinaryToString() and CryptStringToBinary()
|
|
|
|
|
Yes but that gives me a long string how do I make that smaller ?
Thanks.
vg
|
|
|
|
|
Dear James,
In the message above you said we can reduce the buffer by using the function ultoa. But my question is I have to first convert the buffer into ulong and then use the function ultoa. So how do I convert the buffer to ulong because the function ultoa takes in a ulong as its first parameter. So please let me know.
Thanks.
vg
|
|
|
|
|
Hi !!!
In my application, I want to create one dialog box.Which contain 2 small box.
One box will contain name of the components and second box will show preview of the selected component.
Like..Box1 contain.
1.Vessel.
2.Tank.
3.Pump.
4.Nozzle.
5.Exchanger.
6.Fan.
Box 2..
Which show preview of the selected item. like if I will select Fan from the box 1 then it will show me Symbol( .dwg ) of the Fan.
I have collected all symbol (.dwg) for all components..
Now my question is..
1. How can I insert my all .dwg ( autocad drawing)..I.e. which method or class should i used for insert the drawing in my application.
2.How can i show preview ?? Any class or method??
Please help me ...
Thanking you..
Satish
|
|
|
|
|
|
use the <pre> tag to see your message formatted as you like, and please Edit your message instead of reposting a new one
you noticed my message, so there's no need i let mine there
|
|
|
|
|
Does previous messages delete!?
|
|
|
|
|
WhiteSky wrote: Does previous messages delete!?
you wanted to say "Isn't the previous message deleted ?", didn't you ?!
then, yes, so i fixed my consequently. thanks
|
|
|
|
|
You answered to my question but one hours ago;) and I answered to this question 20 minutes ago I think here a problem
|
|
|
|
|
I don't know your answer but one point is that if you want to display drawing from autocad (.dwg files if I understood it well), you'll need a libraray (or whatever) that can read these files.
So, maybe that could be a good starting point: finding how you will load these files.
|
|
|
|
|
Shah Satish wrote: 1. How can I insert my all .dwg ( autocad drawing)..I.e. which method or class should i used for insert the drawing in my application.
Does AutoCAD have some sort of ActiveX control? If not, you'll need to convert the drawings to something that Windows can recognize (e.g., GIF, BMP, JPEG) natively.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|