Missing SHA1 HashAlgorithm

it was so easy with .netmf

using (HashAlgorithm csp = new HashAlgorithm(HashAlgorithmType.SHA1))
byte[] temp = csp.ComputeHash((key + “258EAFA5-E914-47DA-95CA-C5AB0DC85B11”).GetBytes());
accept = System.Convert.ToBase64String(temp);


Why not use md5

because its a technical requirement to use SHA1 and not MD5

Like what? SHA1 is old and not recommended. We need good reasons.

its a “must”


without sha1 no websocket protocol

1 Like

Does this mean we give you sha1 and we get web sockets in return? :grin:

yes thats the case

1 Like
1 Like

Yes, but at one or two orders of magnitude of speed difference… If I had to do this, I would do it as a native plug-in. Not necessarily baked into the base firmware, but something in a module.

Isn’t this only needed for authentication but not for data flow?

SHA is also used for payload signing. SHA is part of the basic table stakes sign/encrypt functionality


RFC 3174 US Secure Hash Algorithm 1 (SHA1)
includes sample code written in c, easier for you to add to your libs…

unfortunately i am not enough familiar with c to convert this to c#

if you delete all the samples c# sha1 using System.Security.Cryptography the internet would have petabytes more free space

1 Like

I used this in the past for web sockets


that was quick!

here’s a piece of code… it seems to made in 2015 :wink:

   private string GetHyBi09Code(string keyValue)

var sha1 = new SHA1();
string tmp = sha1.MessageHash(keyValue.Trim() + “258EAFA5-E914-47DA-95CA-C5AB0DC85B11”);

        var ba = new byte[tmp.Length >> 1];
        int target = 0;
        for (int i = 0; i < tmp.Length; i += 2)
            ba[target++] = tmp.Substring(i, 2).HexByteString2Byte();

return Convert.ToBase64String(ba).ReplaceChar(’!’, ‘+’).ReplaceChar(’*’ ,’/’); // 2015-01-18 .NETMF workaround…
return Convert.ToBase64String(ba);

1 Like


That smells like success.