//C#中使用HMACSHA类
using System;
using SystemSecurityCryptography;
using SystemText;
namespace ExamplesSystemNet
{
public class HMACSHADemo
{
public static void Main(string[] args)
{
string password = Pa$$wrd;
HMACSHA provider = new HMACSHA();
byte[] hashedPassword = providerComputeHash(EncodingDefaultGetBytes(password));
StringBuilder displayString = new StringBuilder();
for (int counter = ; counter < hashedPasswordLength; counter++)
{
displayStringAppend(hashedPassword[counter]ToString(x));
}
ConsoleWriteLine(displayString);
byte[] key = providerKey;
displayString = new StringBuilder();
for (int counter = ; counter < keyLength; counter++)
{
displayStringAppend(key[counter]ToString(x));
}
ConsoleWriteLine(displayString);
ConsoleReadLine();
}
}
}