Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

SHA1 Hashing in asp.net...

  • 26-03-2009 12:41PM
    #1
    Closed Accounts Posts: 7,097 ✭✭✭


    Hi all,

    I'm using the following lines of code to convert a string called newstring into an SHA1 string called password and display it back to the screen:

    string hashMethod = "";

    hashMethod = "SHA1";


    string password = FormsAuthentication.HashPasswordForStoringInConfigFile(newstring, hashMethod);
    Response.Write(password);
    Label2.Text = password.ToString();


    It does exactly what it says on the tin, the only thing is that the hashed result I get is all in uppercase, but when I put the same contents of the newstring variable through several 3rd party websites that offer free SHA1 hashing through their website, I get the same string back, but it is all in lowercase. The only reason I want to keep the results in lowercase is because I have to concatenate another lowercase string onto the hashed
    result I get through the above (which should be in lowercase), and hash it using SHA1 again, so I'm reckoning if one part of the string is not all in lowercase, I could end up with any result...

    I'm wondering is there anyway I can stick in a bit of code to what I have above, to make the value of password all lowercase or to convert it to lowercase without too much of a fuss???

    :confused::confused::confused:


Comments

  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    I have it sorted, I use:

    Label2.Text = password.ToLower();

    Instead of

    Label2.Text = password.ToString();

    Thanks anyone for reading...


Advertisement