Click here to Skip to main content
15,940,246 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to use elastic transcoder of Amazon. Here I need to sha-256 hash a string;

I have tried any ways I have found on the net but I couldn't find the same result as page and some online hashing sites provides.

Here is the string to hash which you can find from the link above;


content-type:application/x-www-form-urlencoded; charset=utf-8


Here is the expected result:


I have tried many c# method but couldn't get this result; but these online sites provides same results;

Here is one of my method;
public static string getHashSha256(string text)
        byte[] bytes = Encoding.UTF8.GetBytes(text);
        SHA256Managed hashstring = new SHA256Managed();
        byte[] hash = hashstring.ComputeHash(bytes);
        string hashString = string.Empty;
        foreach (byte x in hash)
            hashString += String.Format("{0:x2}", x);
        return hashString;

1 solution

Removing \r was the solution

s = s.Replace("\r", "");
Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900