Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3358986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:49:03+00:00 2026-05-18T02:49:03+00:00

Looking for a method or to be pointed in the right direction so I

  • 0

Looking for a method or to be pointed in the right direction so I can return an hash equal to the hash returned by FormsAuthentication.HashPasswordForStoringInConfigFile("asdf", "MD5"). I’ve been trying code like:

        ASCIIEncoding encoding = new ASCIIEncoding();
        encoding.GetBytes("asdf");

        var hashedBytes = MD5.Create().ComputeHash(bytes);
        var password = encoding.GetString(hashedBytes);

I’m not that strong on Hashing so I don’t know where to go next. I always end up with crazy special characters while the FormsAuth method always returns something readable.

Just trying to remove the external dependency to FormAuthentication from some internal business classes.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:49:04+00:00Added an answer on May 18, 2026 at 2:49 am

    Here is the reflector’s output:

    Your problem is not using UTF8

    public static string HashPasswordForStoringInConfigFile(string password, string passwordFormat)
    {
        HashAlgorithm algorithm;
        if (password == null)
        {
            throw new ArgumentNullException("password");
        }
        if (passwordFormat == null)
        {
            throw new ArgumentNullException("passwordFormat");
        }
        if (StringUtil.EqualsIgnoreCase(passwordFormat, "sha1"))
        {
            algorithm = SHA1.Create();
        }
        else
        {
            if (!StringUtil.EqualsIgnoreCase(passwordFormat, "md5"))
            {
                throw new ArgumentException(SR.GetString("InvalidArgumentValue", new object[] { "passwordFormat" }));
            }
            algorithm = MD5.Create();
        }
        return MachineKeySection.ByteArrayToHexString(algorithm.ComputeHash(Encoding.UTF8.GetBytes(password)), 0);
    }
    

    So here is your updated code:

        encoding.GetBytes("asdf");
    
        var hashedBytes = MD5.Create().ComputeHash(bytes);
        var password = Encoding.UTF8.GetString(hashedBytes);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am looking for a method of storing Application Messages, such as You have
I'm looking for a method that computes the line number of a given text
I am looking for a method of reading emails using Pop3 in C# 2.0.
I'm looking for a method to assign variables with patterns in regular expressions with
I am looking for a method to place some text onto the clipboard with
I am looking for a method to compare and sort UTF-8 strings in C++
I'm looking for a method (or function) to strip out the example.ext part of
I'm looking for a method to reliably extract the host name from a URL
I'm looking for a method to obtain the current logged in user's full Active
I am looking for a method of changing the data source for a report

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.