|
|
T M Gray wrote: Ahh he used the wrong control name
Happens all the time, we all get used to it.
|
|
|
|
|
I'm working on loging into an SMF based message board using a WebClient with a cookie collection. So far I've been able to use existing cookies to connect and download pages as needed, however I have to hard code the cookies to do it. Obviously not a good option.
The problem I'm running in to is that in order to have the server generate credentials I have to give it a log in name and a hashed password. The forum login generates them using sha1 hashing with this code:
<br />
doForm.hash_passwrd.value = hex_sha1(hex_sha1(doForm.user.value.php_to8bit().php_strtolower() + doForm.passwrd.value.php_to8bit()) + cur_session_id);<br />
I've been trying to use
<br />
private void btnLogin_Click(object sender, EventArgs e)<br />
{<br />
String sName = "test";<br />
String sPassword = "login";<br />
String sSessionID = "3d847dffa233343cc5065a82b73d566e";<br />
<br />
SHA1 sha = new SHA1CryptoServiceProvider();<br />
byte[] sResult = sha.ComputeHash(StrToByteArray(sName + sPassword));<br />
sResult = sha.ComputeHash(StrToByteArray(ByteArrayToStr(sResult) + sSessionID));<br />
}<br />
<br />
public static byte[] StrToByteArray(string str)<br />
{<br />
return Encoding.UTF8.GetBytes(str);
}<br />
<br />
public static string ByteArrayToStr(byte[] bytes)<br />
{<br />
return BitConverter.ToString(bytes).Replace("-", "").ToLower();<br />
}<br />
<br />
To generate the same hash as the php version...however it's obviously failing. Somewhere in there I'm missing some encoding or particular formatting that I don't know about. Can anyone point me in the right direction here?
EDIT:
<br />
String sName = "test";<br />
String sPassword = "login";<br />
String sSessionID = "8000e537c2a7a31547ffa779fab7a1e2";<br />
String sTemp;<br />
<br />
SHA1CryptoServiceProvider sha = new SHA1CryptoServiceProvider();<br />
sTemp = BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(sName + sPassword))).Replace("-", "").ToLower();<br />
textBox2.Text = BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(sTemp + sSessionID))).Replace("-", "").ToLower();<br />
After beating my head against a wall long enough I was able to come up with this, and it does spit out the exact same hash as the existing php code. This should allow anyone to generate a hash for logging into most SMF powered message boards (They seem to have a niche market in games and mods on a global scale.)
I was a bit surprised to notice codeproject itself doesn't actually hash passwords, it sends them in clear text.
modified on Thursday, July 15, 2010 7:12 AM
|
|
|
|
|
Maybe it should be
byte[] sResult = sha.ComputeHash(StrToByteArray(sName + sPassword));
byte[] sSessionResult =sha.ComputeHash(StrToByteArray(sSessionID));
byte[] returnResult = bew byte[sResult.length + sSessionResult.length];
Array.Copy(sResult, returnResult , 0, sResult.length);
Array.Copy(sSessionResult, returnResult , sResult.length, sSessionResult.length);
sResult = returnResult ;
Fix the compile errors because I just typed this in but I don't think your .NET code matches the PHP code.
|
|
|
|
|
I know the basics of documenting my code for intellisense but I have had alot of trouble finding a good tutorial that shows where the info will be displayed etc.
If anyone knows of a link that would be great.
I could probably find this myself if I knew what MS actually called documenting in this way.
I see things in the framework displaying in intellisense the way that I want but I have had trouble figuring out how they did it.
Thanks again for everyone's help.
Humble Programmer
|
|
|
|
|
Delimiters for Documentation
|
|
|
|
|
Um. Did you mean that as a link, Luc?
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Nope. I decided to leave some room for personal initiative, as I wasn't too impressed by the question.
|
|
|
|
|
I'm impressed - it worked!
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
|
Did you know:
That by counting the rings on a tree trunk, you can tell how many other trees it has slept with.
|
|
|
|
|
Luc Pattyn wrote: personal initiative
Well congrats. Looks like you actually found one with some initiative.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Just what I needed Luc thanks again.
Humble Programmer
|
|
|
|
|
|
Hi...
I want to develop a C File using C#3.0 which will create the header file with structures, enums, macros..and all other features of the C..
I want to develop a tool in which i have a GUI and i have to select the options from GUI and accordingly i have to create a C file for the same
So is it possible in C#3.0?
|
|
|
|
|
Sounds like an IDE. A C-sourcefile is usually in ASCII, meaning that it's plain text. You can compile this source off course, even using an external compiler.
Should I imagine a code-generator, or more of a forms-generator?
I are Troll
|
|
|
|
|
thanks for ur reply..
Basically I am doing a project in which i will be designing a GUI and from there by taking the input I want to generate the C code in a file with ".C" extension. I will be using a different compiler to compile that C File.
So is it possible?
|
|
|
|
|
Yup. There's some articles on CodeProject that deal with creating User-Interfaces, in a similar way that Visual Studio works.
This[^] site shows how to create Windows and buttons from C.
You'd have to generate source-code similar to that on the website. Most compilers can be run from the command-line, so that shouldn't be any problem.
I are Troll
|
|
|
|
|
It sounds IDE kind of stuff you are looking for.
According to my knowledge currently there is no
any existing project or tool available which can
assist you.
However, it sounds R&D kind of project.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Niungareamit wrote: So is it possible in C#3.0?
My last team leader used to say "everything is possible with software", and I would agree. The question you really need to ask is whether you are able to translate user input selections into a valid C program.
It's time for a new signature.
|
|
|
|
|
I would recommend using an XML file to represent your C file. If you manipulate a .c file directly when you add or remove something like and include you have to do a whole lot more to find the correct line and insert or remove the text you want.
If you use an XML file you could have an includes node, and in C# you just add and remove nodes to the tree as you please. You can also have class nodes which in turn have method nodes and so on. Then you use XSLT to turn the XML into a .c file.
|
|
|
|
|
I don't know why you were downvoted.
Of course it is possible and maybe even useful.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Agreed
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi,
How to disable selection in datagridview?
I used datagridview1.ClearSelection();
it cleared the selection. But, I would like to restrict the user not to select the data. Please let me know how to achieve this. Thanks in advance.
|
|
|
|
|
You have two choices for the same.
1. If you want to allow selection for certain rows and disable selection
for other rows then try following.
If SelectionMode is FullRowSelect, then you'll need to override SetSelectedRowCore for that DataGridView, and not call the base SetSelectedRowCore for rows you don't want selected.
If SelectionMode is not FullRowSelect, you'll want to additionally override SetSelectedCellCore (and not call the base SetSelectedCellCore for rows you don't want selected), as SetSelectedRowCore will only kick in if you click the row header and not an individual cell.
2. Try following.
private void dataGridView1_SelectionChanged(object sender, EventArgs e)
{
if (this.dataGridView1.SelectedCells.Count > 0)
{
this.dataGridView1.SelectedCells[0].Selected = false;
}
}
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|