熱點推薦:
您现在的位置: 電腦知識網 >> 編程 >> .NET編程 >> 正文

C#中的HMACSHA1類

2022-06-13   來源: .NET編程 

  //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();

  }

  }

  }


From:http://tw.wingwit.com/Article/program/net/201311/13678.html
    推薦文章
    Copyright © 2005-2022 電腦知識網 Computer Knowledge   All rights reserved.