This site is deprecated; docs have moved to!

SHA256 HMAC In CSharp

From the makers of InspIRCd.
Revision as of 06:41, 8 January 2015 by SaberUK (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Development Development Material - Information posted here is for developer reference only. This material is subject to possible change and will be technical in nature.

The following is an implementation of the SHA256 HMAC authentication used in protocol versions 1202 and above:

using System.Text;
using System.Security.Cryptography;

public static string GenerateNewHMAC(string password, string challenge)
       HMACSHA256 hmc = new HMACSHA256(Encoding.ASCII.GetBytes(password));
       byte[] hmres = hmc.ComputeHash(Encoding.ASCII.GetBytes(challenge));
       return Convert.ToBase64String(hmres).Replace("=", "");