Click here to Skip to main content
15,881,882 members
Home / Discussions / C#
   

C#

 
GeneralRe: How do I format Column when a Gridview loads? Pin
roman_s14-Jul-10 10:06
roman_s14-Jul-10 10:06 
GeneralRe: How do I format Column when a Gridview loads? Pin
Luc Pattyn14-Jul-10 10:18
sitebuilderLuc Pattyn14-Jul-10 10:18 
GeneralRe: How do I format Column when a Gridview loads? Pin
roman_s14-Jul-10 10:31
roman_s14-Jul-10 10:31 
AnswerRe: How do I format Column when a Gridview loads? Pin
T M Gray14-Jul-10 10:17
T M Gray14-Jul-10 10:17 
GeneralRe: How do I format Column when a Gridview loads? Pin
Luc Pattyn14-Jul-10 10:21
sitebuilderLuc Pattyn14-Jul-10 10:21 
GeneralRe: How do I format Column when a Gridview loads? Pin
T M Gray14-Jul-10 10:37
T M Gray14-Jul-10 10:37 
GeneralRe: How do I format Column when a Gridview loads? Pin
Luc Pattyn14-Jul-10 11:08
sitebuilderLuc Pattyn14-Jul-10 11:08 
QuestionSMF Forum login using webclient [modified] Pin
Skymir14-Jul-10 8:06
Skymir14-Jul-10 8:06 
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); //encoding.GetBytes(str);<br />
        }<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

AnswerRe: SMF Forum login using webclient Pin
Ennis Ray Lynch, Jr.14-Jul-10 9:00
Ennis Ray Lynch, Jr.14-Jul-10 9:00 
QuestionIntellisense Documenation Pin
programmervb.netc++14-Jul-10 4:44
programmervb.netc++14-Jul-10 4:44 
AnswerRe: Intellisense Documenation Pin
Luc Pattyn14-Jul-10 5:06
sitebuilderLuc Pattyn14-Jul-10 5:06 
GeneralRe: Intellisense Documenation Pin
OriginalGriff14-Jul-10 5:18
mveOriginalGriff14-Jul-10 5:18 
GeneralRe: Intellisense Documenation Pin
Luc Pattyn14-Jul-10 5:23
sitebuilderLuc Pattyn14-Jul-10 5:23 
GeneralRe: Intellisense Documenation Pin
OriginalGriff14-Jul-10 6:00
mveOriginalGriff14-Jul-10 6:00 
GeneralRe: Intellisense Documenation Pin
Luc Pattyn14-Jul-10 6:38
sitebuilderLuc Pattyn14-Jul-10 6:38 
GeneralRe: Intellisense Documenation Pin
OriginalGriff14-Jul-10 8:11
mveOriginalGriff14-Jul-10 8:11 
GeneralRe: Intellisense Documenation Pin
Wes Aday14-Jul-10 6:28
professionalWes Aday14-Jul-10 6:28 
GeneralRe: Intellisense Documenation Pin
programmervb.netc++14-Jul-10 5:26
programmervb.netc++14-Jul-10 5:26 
AnswerRe: Intellisense Documenation Pin
Ennis Ray Lynch, Jr.14-Jul-10 5:09
Ennis Ray Lynch, Jr.14-Jul-10 5:09 
QuestionGenerating C file using C# Pin
Niungareamit14-Jul-10 3:03
Niungareamit14-Jul-10 3:03 
AnswerRe: Generating C file using C# Pin
Eddy Vluggen14-Jul-10 3:12
professionalEddy Vluggen14-Jul-10 3:12 
GeneralRe: Generating C file using C# Pin
Niungareamit14-Jul-10 3:50
Niungareamit14-Jul-10 3:50 
GeneralRe: Generating C file using C# Pin
Eddy Vluggen14-Jul-10 4:03
professionalEddy Vluggen14-Jul-10 4:03 
AnswerRe: Generating C file using C# Pin
Peace ON14-Jul-10 3:22
Peace ON14-Jul-10 3:22 
AnswerRe: Generating C file using C# Pin
Richard MacCutchan14-Jul-10 5:58
mveRichard MacCutchan14-Jul-10 5:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.