Unable to login into my application after Using Hashbytes in Sql code

  • Hi,

    I have generated a script which imports data from an excel sheet & updates into client table. the script inserts the password into the password field using the hashbytes function as shown below

    HashBytes('MD5',@Password)

    The MD5 algorithm used in my application to create password is:

    public string MD5Encryption(string password)

    {

    byte[] pass = Encoding.UTF8.GetBytes(password);

    MD5 md5 = new MD5CryptoServiceProvider();

    string strpassword =

    Encoding.UTF8.GetString(md5.ComputeHash(pass));

    return strpassword;

    }

    I am unable to login with the client credentials. What could be the reason

  • No idea with the little that you've shown.

    What did you do with the 'password field'? What's the login error message?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • I am unable to login with the client credentials.

    Where are you not able to login to, SQL Server / Application? If SQL Server what’s the error you are getting?

    For Application, please check whether your encryption / decryption are working properly.

  • Under normal circumstances the client is created using the application. When the clients to be created is high they provide me an excel to populate the tables. There is no issue inserting into the tables.

    When I try logging in from my application I get the error Invalid Login Credentials. At the application level they are using MD5 algorithm to encrypt the password, so I used the function:

    HashBytes('MD5',@Password)

    INSERT INTO client (....,password)

    VALUES(....,HashBytes('MD5',@Password))

    to encrypt the password & insert into the table.

  • Not enough information. I can't see your screen, I can't read your mind.

    What is the code for the login? Where does that error get thrown from and for what reason (it'll be in the code somewhere)? What's the data type of the password column?

    p.s. MD5 is not an encryption algorithm. It's a hashing algorithm.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply