Snip2Code is shutting down.
It has been quite a ride, since 2013 when we launched our first prototype: thanks to the effort of you guys we collected more than 3 million snippets!
We are very proud to help all our users to be more efficient in their jobs, and to be the central point to share programming knowledge for everyone.
Our basic service is free, so we always survived on our own resources to give you Snip2Code.
Unfortunately, we are no more in the financial position to sustain this effort, and therefore we are announcing here our permanent shut down,
which will take place on August 1st, 2020.
Please save your private snippets using our backup function in the settings, here.
IF YOU WANT TO SAVE SNIP2CODE, PLEASE CONSIDER DOING A DONATION!
This will allow us to pay for the servers and the infrastructure. If you want to donate, Contact Us!
by
84k 18
0
5
1,002
0
Top 1% !
Popular
Famous
Tagged
Specified
Popularity: 38086th place
This snippet is Public
Architecturex86_64
LanguageC#
Windows VersionWindows7

HmacSha256

Because Windows.Security.Cryptography.Core.MacAlgorithmNames.HmacSha256 doesn't exist in WP8.1 context we need to do another implementation
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1369491/HmacSha256?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
using System; using System.Collections.Generic; using System.Linq; using System.Net; using System.Text; using System.Threading.Tasks; using Windows.Security.Cryptography; using Windows.Security.Cryptography.Core; using Windows.Web.Http; using Windows.Web.Http.Headers; // Because Windows.Security.Cryptography.Core.MacAlgorithmNames.HmacSha256 doesn't // exist in WP8.1 context we need to do another implementation public static string HmacSha256(string key, string value) { var keyStrm = CryptographicBuffer.ConvertStringToBinary(key, BinaryStringEncoding.Utf8); var valueStrm = CryptographicBuffer.ConvertStringToBinary(value, BinaryStringEncoding.Utf8); var objMacProv = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256); var hash = objMacProv.CreateHash(keyStrm); hash.Append(valueStrm); return CryptographicBuffer.EncodeToBase64String(hash.GetValueAndReset()); }
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus