Hash 使用类似“fQ6x8I******”的盐。我从你的帖子中得到了一个想法,你能告诉我要添加哪些引用才能使代码正常工作吗。如果你能键入一个小程序来生成pbkdf2_sha256哈希值来进行演示,这将对我非常有帮助。我是新来的。@@@@@感谢您的回复,这真的很有
Hash 使用类似“fQ6x8I******”的盐。我从你的帖子中得到了一个想法,你能告诉我要添加哪些引用才能使代码正常工作吗。如果你能键入一个小程序来生成pbkdf2_sha256哈希值来进行演示,这将对我非常有帮助。我是新来的。@@@@@感谢您的回复,这真的很有,hash,salt,.net,pbkdf2,Hash,Salt,.net,Pbkdf2,使用类似“fQ6x8I******”的盐。我从你的帖子中得到了一个想法,你能告诉我要添加哪些引用才能使代码正常工作吗。如果你能键入一个小程序来生成pbkdf2_sha256哈希值来进行演示,这将对我非常有帮助。我是新来的。@@@@@感谢您的回复,这真的很有帮助@@@I我尝试了您提供的代码,我收到错误CS1729'Rfc2898DeriveBytes'不包含接受4参数的构造函数您需要使用.NET Core 2.0并根据netcoreapp20TFM进行编译才能使用新的4参数构造函数。抱歉,我是新来
使用类似“fQ6x8I******”的盐。我从你的帖子中得到了一个想法,你能告诉我要添加哪些引用才能使代码正常工作吗。如果你能键入一个小程序来生成pbkdf2_sha256哈希值来进行演示,这将对我非常有帮助。我是新来的。@@@@@感谢您的回复,这真的很有帮助@@@I我尝试了您提供的代码,我收到错误CS1729'Rfc2898DeriveBytes'不包含接受4参数的构造函数您需要使用.NET Core 2.0并根据
netcoreapp20
TFM进行编译才能使用新的4参数构造函数。抱歉,我是新来的。。。。。。。。.Net Core 2.0是一个NuGet软件包吗。。。。。。。。。。。以及针对netcoreapp20进行编译意味着什么?。。。好的,明白了。net core 2.0是一个.net版本,对吗?…谢谢你安装了.net core 2.0。但是在菜单中没有显示任何选项,我可以在其中更改我的.net framework版本(我项目的属性)。是否可用于WPF应用程序?如果是这样的话,那就使用它吧。我没有那么多时间来完成,请帮忙@@@@@@@@@@多谢各位@@@
var salt = "FbSnXHPo12gb";
var password = "geheim";
var interactions = 12000;
using (var hmac = new HMACSHA256())
{
var df = new Pbkdf2(hmac, password, salt, interactions);
Console.WriteLine(Convert.ToBase64String(df.GetBytes(32)));
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MySql.Data.MySqlClient;
using System.IO;
using System.Security.Cryptography;
namespace login
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void login_Click(object sender, RoutedEventArgs e)
{
var salt = "FbSnXHPo12gb";
var password = "geheim";
var interactions = 12000;
using (var hmac = new HMACSHA256())
{
var df = new Pbkdf2(hmac, password, salt, interactions);
Console.WriteLine(Convert.ToBase64String(df.GetBytes(32)));
}
string myConnection = "datasource=localhost;port=3306;username=root;password=abcde12345 ; database=finalproject";
MySqlConnection myConn = new MySqlConnection(myConnection);
MySqlCommand SelectCommand = new MySqlCommand("select * from login where Username='" + this.username.Text + "' and Password='" + this.password.Password + "';", myConn);
MySqlDataReader myReader;
myConn.Open();
myReader = SelectCommand.ExecuteReader();
int count = 0;
while (myReader.Read())
{
count = count + 1;
}
if (count == 1)
{
MessageBox.Show("Hello");
}
else
{
MessageBox.Show("Wrong username and password");
}
myConn.Close();
}
}
}
byte[] saltBytes = Convert.FromBase64String(salt);
byte[] derived;
using (var pbkdf2 = new Rfc2898DeriveBytes(password, saltBytes, interactionCount))
{
derived = pbkdf2.GetBytes(32);
}
using (var pbkdf2 = new Rfc2898DeriveBytes(
password,
saltBytes,
interactionCount,
HashAlgorithmName.SHA256))
{
derived = pbkdf2.GetBytes(32);
}