User account password check with C#.NET in hMail Server 5

This section contains scripts that hMailServer has contributed with. hMailServer 5 is needed to use these.
Post Reply
mfozdemir
New user
New user
Posts: 4
Joined: 2010-07-31 23:38
Location: TURKEY
Contact:

User account password check with C#.NET in hMail Server 5

Post by mfozdemir » 2010-08-01 00:23

I read this article as http://www.hmailserver.com/forum/viewto ... 20&t=18307. After, I say my self to public code in c#. No more words needed to describe...

Code: Select all

        //This code check password with SHA-256  for hMailServer 5 and more
        //creator: Fatih OZDEMIR
        //Date: 2010-08-01
        //Returns: True / False
        //Copyright: GNU
        public bool CheckPass(string pass, string HashPassFromDB)
        {
            //Sql user Pass length= 70 character
            // userpassword=SALT(6)+HASH(64)
            string salt = HashPassFromDB.Substring(0, 6);
            SHA256 sha = SHA256.Create(); //using System.Security.Cryptography;
            //HASH(64)= SHA256(SALT(6) + pass)
            byte[] hashByte = sha.ComputeHash(Encoding.Default.GetBytes(salt + pass));
            StringBuilder s_builder = new StringBuilder();
            foreach (byte b in hashByte)
            {
                s_builder.Append(b.ToString("x2"));
            }

            // userpassword=SALT(6)+HASH(64)
            string passCripto = salt + s_builder.ToString();

            //compare results
            if (passCripto == HashPassFromDB) return true;
            else return false;
        }
best regards...

chromebuster
Normal user
Normal user
Posts: 60
Joined: 2010-05-01 04:47
Location: New England, USA
Contact:

Re: User account password check with C#.NET in hMail Server

Post by chromebuster » 2010-11-17 04:46

But the real question is how on earth do you deploy it into the server and then use it?

mfozdemir
New user
New user
Posts: 4
Joined: 2010-07-31 23:38
Location: TURKEY
Contact:

Re: User account password check with C#.NET in hMail Server

Post by mfozdemir » 2010-12-19 17:28

I don't understand your question? please expend your question..

chromebuster
Normal user
Normal user
Posts: 60
Joined: 2010-05-01 04:47
Location: New England, USA
Contact:

Re: User account password check with C#.NET in hMail Server

Post by chromebuster » 2011-03-06 03:22

What I mean is, is this a stand-alone program, or does it have to be deployed somehow into HMailServer itself?

mfozdemir
New user
New user
Posts: 4
Joined: 2010-07-31 23:38
Location: TURKEY
Contact:

Re: User account password check with C#.NET in hMail Server

Post by mfozdemir » 2011-04-03 03:12

You are true.. I do not had to be integrated with another program to Hmail. Then I reviewed the data base. After I developed a module for creating and managing user accounts. I've used it for. In the meantime, have prepared a very simple web interface. is easy to develop. :))

User avatar
dzekas
Senior user
Senior user
Posts: 2486
Joined: 2005-10-13 21:28
Location: Lithuania

Re: User account password check with C#.NET in hMail Server

Post by dzekas » 2011-04-03 08:46

mfozdemir wrote:You are true.. I do not had to be integrated with another program to Hmail. Then I reviewed the data base. After I developed a module for creating and managing user accounts. I've used it for. In the meantime, have prepared a very simple web interface. is easy to develop. :))
your code checks only default hash/encryption method for v5. One out of four.

mfozdemir
New user
New user
Posts: 4
Joined: 2010-07-31 23:38
Location: TURKEY
Contact:

Re: User account password check with C#.NET in hMail Server

Post by mfozdemir » 2011-04-03 13:58

I know it .. I just needed to reach users in the Hmail database.. I Shared to help.

thedealer
New user
New user
Posts: 7
Joined: 2011-07-14 18:39

Re: User account password check with C#.NET in hMail Server

Post by thedealer » 2011-07-15 17:47

mfozdemir wrote:You are true.. I do not had to be integrated with another program to Hmail. Then I reviewed the data base. After I developed a module for creating and managing user accounts. I've used it for. In the meantime, have prepared a very simple web interface. is easy to develop. :))
Would love to toy around with this interface if you are willing to let a stranger step in and fiddle around.

Post Reply