|
thanks randor
can u help me to convert c# code in c++;
my code works gud in c# but I have not so much idea how these functions works in c++
static string convert_byte_array_to_string(byte[] byte_array)
{
string hashString = "";
for (int i = 0; i < byte_array.Length; i++)
{
hashString += Convert.ToString(byte_array[i], 16).PadLeft(2, '0');
}
return hashString;
}
MD5 md5Hash = MD5.Create();
byte[] str_Buf = System.Text.UnicodeEncoding.Unicode.GetBytes(value_str);
hashString = Form1.convert_byte_array_to_string(str_Buf);
byte[] strHash = md5Hash.ComputeHash(str_Buf);
hashString = Form1.convert_byte_array_to_string(strHash);
byte[] hashBuf = new byte[21 * 16];
for (int i = 0; i < 16; i++)
{
Array.Copy(strHash, 0, hashBuf, i * 21, 5);
Array.Copy(verifierBuf, 0, hashBuf, i * 21 + 5, 16);
}
hashString = Form1.convert_byte_array_to_string(hashBuf);
strHash = md5Hash.ComputeHash(hashBuf);
hashString = Form1.convert_byte_array_to_string(strHash);
uint block = 0;
Array.Copy(strHash, 0, hashBuf, 0, 5);
Array.Copy(BitConverter.GetBytes(block), 0, hashBuf, 5, 4);
hashString = Form1.convert_byte_array_to_string(hashBuf);
strHash = md5Hash.ComputeHash(hashBuf, 0, 9);
hashString = Form1.convert_byte_array_to_string(strHash);
byte[] rc4Key = new byte[16];
Array.Copy(strHash, rc4Key, 16);
hashString = Form1.convert_byte_array_to_string(rc4Key);
ManagedRC4.RC4 rc4 = new ManagedRC4.RC4();
rc4.Init(rc4Key, (uint)rc4Key.Length);
rc4.Decrypt(encryptedVerifier, (uint)encryptedVerifier.Length);
rc4.Decrypt(encryptedVerifierHash, (uint)encryptedVerifierHash.Length);
hashString = Form1.convert_byte_array_to_string(encryptedVerifier);
hashString = Form1.convert_byte_array_to_string(encryptedVerifierHash);
byte[] hashedVerifier = md5Hash.ComputeHash(encryptedVerifier);
hashString = Form1.convert_byte_array_to_string(hashedVerifier);
hashString = Form1.convert_byte_array_to_string(encryptedVerifier);
md5Hash.Clear();
please.
can I create dll for c code and use in my c++ code.
can u please help me for this.
modified 28-Dec-13 7:22am.
|
|
|
|
|
Hello....I am learning C and C++ and I find pointer as a very tough topic. Its really very hard to understand its key points. I want to know is there any difference in pointers of C and C++? And also how can I learn this topic easily.Thanks.
|
|
|
|
|
Pointers are the same in both versions of the language; they point to elements or objects. In reality a pointer is merely a convenient way of addressing a portion of memory. for example:
char someArray[256]; char* pItemOfArray = someArray;
while (*pItemOfArray != '\0') {
*pItemArray = *pItemArray + 1; pItemArray++; }
Veni, vidi, abiit domum
|
|
|
|
|
akstgsb wrote: nd I find pointer as a very tough topic. And also how can I learn this topic easily.
You can't. You are already finding it tough so it is going to be tough until you finally (hopefully) get it.
It might help to find different sources and read different explanations of it. Or not.
If it helps any when I first encountered pointers it took me about a year to really get them.
|
|
|
|
|
Simple. Learn ASM - then pointers will be the least of your concerns!
No, on a serious note (although, I am only 1/2 joking) - as jschell says, they're a tricky topic for most. There really isn't a direct counterpart in the physical world. You either get them, or you dont. (or you think you do, but dont )
One way to think of them may be to consider a pointer as a single entry in either the Table Of Contents or Index of a book. The pointer in itself doesn't tell you what the data is, it merely tells you where to find it. - The analogy breaks-down however, when you consider that the pointer doesn't tell you what it holds. Whereas the book-based counterparts tell you where to find the information, and give you a good clue as to what they hold.
An image of linked-lists may help for the concept of pointers to take root in your mind.
|
|
|
|
|
How to parse xml using QXmlstreamreader in QT without premature document error?
|
|
|
|
|
|
void CxmlRd::parseXML()
{
QString xmlFile= "D:/Neethu/xmlRd/sample.xml";
QFile *xml= new QFile(xmlFile);
QXmlStreamReader r(xml);
if(!xml->open(QFile::ReadWrite|QIODevice::Text))
{
QMessageBox::critical(this,
"QXSRExample::parseXML",
"Cannot Open file",
QMessageBox::Ok);
}
while(!r.atEnd())
{
if(r.readNextStartElement())
{
ui->textEdit->append("found element");
}
if(r.hasError())
{
QMessageBox::critical(this,
"QXSRExample::parseXML",
r.errorString(),
QMessageBox::Ok);
}
}
}
|
|
|
|
|
|
Hello there,
I am working on a Windows application using Visual Studio 2012. One of the screens have a text entry field for the user. Instead of using a standard text field control, am placing a image which looks exactly like a text field. Now what i want to do is, capture the key stroke and update this image with the characters entered by user.
The initial image shown to the user is "Blank_Text_Entry.png" and this is added to the resource as IDB_BLANK_TEXT_ENTRY.
This is a rectangular white image with dimensions 153 x 27, with a size of 250 bytes.
My goal is to be able to update this image dynamically based on key strokes by user and display it.
Is it possible to do something like this? If yes, can anyone share some sample code?
Thanks in advance.
|
|
|
|
|
You can sure do that... but it seems WAY more painful than taking a text control and adapting it to do whatever it is you want.
If I may ask, why is it that you want to draw it yourself rather than changing an existing field control?
BTW, the way you would do it is by custom drawing using something like GDI. Easiest way would be to draw the blank entry box first, then update it with textual line items... problem is making it look and act nice would be a pain.
|
|
|
|
|
hi all,
can anybody help me to identify the file type and its protection type at the time when browse from location.
thanks.
|
|
|
|
|
Which file and how are you trying to access it? Please try and be a little more clear and detailed in your questions, and explain what actual coding problem you are trying to solve.
Veni, vidi, abiit domum
|
|
|
|
|
I want know the the file type like ms office 2007,ms office 2003 and so on
and protection type 40 bit encryption or 128AES for word file.
I want to such type of file details when I browse the file from my system.
|
|
|
|
|
The file type can be guessed from the extension, although that does not guarantee the content. It is not possible to guess the encryption type; after all that is part of the reason for encryption, to hide information about the file's contents.
Veni, vidi, abiit domum
|
|
|
|
|
Hi,
I am using DirectShow for playing video and VRM9 as a renderer. I want to resize my video but the result is a choppy with a kind of pixelated effect.
I want a smooth interpolated picture as you can see on different media players. Does VRM9 have something to enable or is something to implement by my own ?
Regards,
sdancer75
|
|
|
|
|
Any suggestion here ? Is there any anti-aliasing method for the video playback ?
sdancer75
|
|
|
|
|
Solved ! VMR9 under vista and later OS does not support interpolation. Microsoft removed this functionality to enforce programmers to use the new EVR renderer.
Shity thoughts from a company like MS!
sdancer75
|
|
|
|
|
Hi to all, I am writing a program which will copy a directory tree and delete the source, every thing works as planned, but given that a reparse point could point anywhere (even network drives), one need to be careful when deleting recursively, it could end up deleting way more than on a target system.
How to deal with this situation when dealing with FILE_ATTRIBUTE_REPARSE_POINT, whether it is a recursive copy routine or delete routine.
Regards,
Vishal
|
|
|
|
|
|
|
vishalgpt wrote: I am writing a program which will copy a directory tree and delete the source
Do you have an actual business case for this?
vishalgpt wrote: How to deal with this situation when dealing with FILE_ATTRIBUTE_REPARSE_POINT
Depends on your business case but one very obvious and easy solution involves the following steps.
- Stop
- Report an error.
Some more complex solutions would be to span the tree before starting and refuse to continue if any problems are found.
Just curious what is your application going to do if the the files/directories are in use when you are deleting (which is probably much more likely than what you are asking.)
|
|
|
|
|
Been told by gurus that this is legal. It does compile in VC.
But since when?
It makes no sense to me. SO how big is the memory footprint?
Thanks for your time.
long unsigned int foo;
|
|
|
|
|
I've read that the position of the word unsigned isn't important, though I'm not sure if this is an addition made over the years, or if it has been a part of c (&c++) since day 0.
sizeof(long) and sizeof(int) are both the same on a 32 bit system - 4. If memory serves me correctly, in the old days of my experience with 16-Bit turbo C++ 3.1, a long was 4 bytes long and an int was 2 bytes. Not sure if the sizeof operator returns the largest of the two or something else. sizeof(long long) for instance, is 8. So, I don't know if long int is a type in and of itself, as long long is, or if its seen as being a long modification of the int data type.
The StackOverflow community generally have someone online with the c/c++ specs seemingly committed to memory.
Interesting question.
|
|
|
|
|
I just tried this:
long long unsigned int llui;
unsigned int ui;
unsigned long ul;
cout << "long long unsigned int: " << sizeof(llui) << endl;
cout << " unsigned int: " << sizeof(ui) << endl;
cout << " unsigned long: " << sizeof(ul) << endl;
resulting in:
long long unsigned int: 8
unsigned int: 4
unsigned long: 4
It appears that the compiler accepts all specifications and creates the largest item. The results are the same whether unsigned or not.
Veni, vidi, abiit domum
|
|
|
|