0

このメソッドが MainWindow.xaml.cs の拡張メソッドとして表示されませんでした。

MainWindow に、次を追加しました: using WpfApplication1_WPF.Classes;

教えてください。

これはコードです:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Runtime.CompilerServices;
using System.Data.Objects;

namespace WpfApplication1_WPF.Classes
{
public static class Extensions 
{
      //1-Convert the user input to hash 
      public static String Hashed(String dataToHash)
      {
         //Convert dataToHash to byte array
         byte[] plainTextBytes = Encoding.Unicode.GetBytes(dataToHash);

         //Computer hash of bytes using SHA256 (256 bit hash value)
         //Convert text to hash by using ComputerHash function in SHA256Managed algorithm
         byte[] hash = new SHA256Managed().ComputeHash(plainTextBytes);

         //Return hashed bytes as encoded string 
         //[convert hash byte to string to be saved in DB]
         return Convert.ToBase64String(hash);
       }
  }
}
4

1 に答える 1

2

署名に次を追加します

public static String Hashed(this String dataToHash)

this入力パラメーターの前に必要です。

于 2013-10-21T23:28:49.947 に答える