Click here to Skip to main content
15,393,026 members
Home / Discussions / C#
   

C#

 
GeneralRe: Accessing mdiParent form menu from mdiChild form via code Pin
Dave Kreskowiak15-Jul-10 2:02
mveDave Kreskowiak15-Jul-10 2:02 
AnswerRe: Accessing mdiParent form menu from mdiChild form via code [modified] Pin
DaveyM6914-Jul-10 23:54
professionalDaveyM6914-Jul-10 23:54 
GeneralRe: Accessing mdiParent form menu from mdiChild form via code Pin
AussieLew15-Jul-10 23:11
MemberAussieLew15-Jul-10 23:11 
GeneralRe: Accessing mdiParent form menu from mdiChild form via code Pin
DaveyM6917-Jul-10 0:35
professionalDaveyM6917-Jul-10 0:35 
GeneralRe: Accessing mdiParent form menu from mdiChild form via code Pin
AussieLew27-Jul-10 13:08
MemberAussieLew27-Jul-10 13:08 
GeneralRe: Accessing mdiParent form menu from mdiChild form via code Pin
DaveyM6930-Jul-10 10:47
professionalDaveyM6930-Jul-10 10:47 
GeneralRe: Accessing mdiParent form menu from mdiChild form via code Pin
AussieLew30-Jul-10 22:51
MemberAussieLew30-Jul-10 22:51 
GeneralRe: Accessing mdiParent form menu from mdiChild form via code Pin
DaveyM6931-Jul-10 0:13
professionalDaveyM6931-Jul-10 0:13 
QuestionList.Sort() Stability? Reliability...? Pin
ely_bob14-Jul-10 14:41
professionalely_bob14-Jul-10 14:41 
AnswerRe: List.Sort() Stability? Reliability...? Pin
Luc Pattyn14-Jul-10 15:17
sitebuilderLuc Pattyn14-Jul-10 15:17 
GeneralRe: List.Sort() Stability? Reliability...? Pin
Ennis Ray Lynch, Jr.15-Jul-10 3:22
MemberEnnis Ray Lynch, Jr.15-Jul-10 3:22 
GeneralRe: List.Sort() Stability? Reliability...? Pin
Richard Blythe15-Jul-10 6:37
MemberRichard Blythe15-Jul-10 6:37 
GeneralRe: List.Sort() Stability? Reliability...? Pin
Richard Blythe15-Jul-10 6:39
MemberRichard Blythe15-Jul-10 6:39 
AnswerRe: List.Sort() Stability? Reliability...? Pin
Luc Pattyn15-Jul-10 7:15
sitebuilderLuc Pattyn15-Jul-10 7:15 
AnswerRe: List.Sort() Stability? Reliability...? Pin
Pete O'Hanlon15-Jul-10 10:37
mvaPete O'Hanlon15-Jul-10 10:37 
QuestionHow do I format Column when a Gridview loads? Pin
roman_s14-Jul-10 9:14
Memberroman_s14-Jul-10 9:14 
AnswerRe: How do I format Column when a Gridview loads? Pin
Luc Pattyn14-Jul-10 9:35
sitebuilderLuc Pattyn14-Jul-10 9:35 
GeneralRe: How do I format Column when a Gridview loads? Pin
roman_s14-Jul-10 10:06
Memberroman_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
Memberroman_s14-Jul-10 10:31 
AnswerRe: How do I format Column when a Gridview loads? Pin
T M Gray14-Jul-10 10:17
MemberT 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
MemberT 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
MemberSkymir14-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

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.