/ / मैन्युअल रूप से परिवर्तित पासवर्ड और नमक ASPNETDB पासवर्ड के साथ तुलना करने के लिए - c #, asp.net, .net, हैश

एएसपीएनईटीडीबी पासवर्ड के साथ तुलना करने के लिए पासवर्ड और नमक को मैन्युअल रूप से कनवर्ट करना - सी #, एएसपीनेट, नेट, हैश

मैं मैन्युअल रूप से एस्पनेटडब की तुलना करने की कोशिश कर रहा हूंवैधता की जांच करने के लिए मेरे अंत में एक मैन्युअल-हैशेड पासवर्ड के साथ पासवर्ड फ़ील्ड (मैं डिफ़ॉल्ट सदस्यता कार्यान्वयन का उपयोग नहीं कर सकता क्योंकि मैं एक कस्टम का उपयोग कर रहा हूं)। वैसे भी, मैं रिकॉर्ड से Base64 पासवर्ड नमक ले रहा हूं, और नमकीन हैश पाने के लिए निम्नलिखित एल्गोरिथ्म का उपयोग कर रहा हूं:

static byte[] GenerateSaltedHash(byte[] plainText, byte[] salt)
{
HashAlgorithm algorithm = new SHA256Managed();

byte[] plainTextWithSaltBytes =
new byte[plainText.Length + salt.Length];

for (int i = 0; i < plainText.Length; i++)
{
plainTextWithSaltBytes[i] = plainText[i];
}
for (int i = 0; i < salt.Length; i++)
{
plainTextWithSaltBytes[plainText.Length + i] = salt[i];
}

byte[] hash = algorithm.ComputeHash(plainTextWithSaltBytes);

return hash;
}

मैं तो उन बाइट्स ले और एक के साथ तुलना करेंConvert.GetBase64Bytes (MembershipUser.Password)। वहाँ एक डिस्कनेक्ट कहीं है, हालांकि बाइट्स के रूप में मैं कन्वर्ट विधि से मिलता है और मेरी गणना की गई हैश भी कभी नहीं कर रहे हैं जब भी मुझे पता है कि पासवर्ड समान हैं

मैं कहाँ गलत हो रहा है पर कोई अंतर्दृष्टि?

उत्तर:

जवाब के लिए 0 № 1

SqlMembershipProvider के स्रोत को देखने पर, ऐसा प्रतीत होता है कि वे नमक की नकल करते हैं से पहले पासवर्ड:

static byte[] GenerateSaltedHash(byte[] plainText, byte[] salt)
{
HashAlgorithm algorithm = new SHA256Managed();

byte[] plainTextWithSaltBytes = new byte[plainText.Length + salt.Length];
salt.CopyTo(plainTextWithSaltBytes, 0);
plainText.CopyTo(plainTextWithSaltBytes, salt.Length);

byte[] hash = algorithm.ComputeHash(plainTextWithSaltBytes);

return hash;
}