|
@@ -1787,7 +1787,7 @@ namespace TEAMModelOS.Controllers
|
|
|
json.RootElement.TryGetProperty("pw", out JsonElement dbpw);
|
|
|
json.RootElement.TryGetProperty("name", out JsonElement name);
|
|
|
|
|
|
- var HashedPW = HashedPassword(pw.ToString(), salt.ToString());
|
|
|
+ var HashedPW = Utils.HashedPassword(pw.ToString(), salt.ToString());
|
|
|
if (dbpw.ToString().Equals(HashedPW.ToString()))
|
|
|
{
|
|
|
//換取AuthToken,提供給前端
|
|
@@ -1851,18 +1851,5 @@ namespace TEAMModelOS.Controllers
|
|
|
return Ok(new { error, auth_token, blob_uri, blob_sas, classinfo, courses });
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public static string HashedPassword(string password, string salt)
|
|
|
- {
|
|
|
- byte[] hashBytes = KeyDerivation.Pbkdf2(
|
|
|
- password: password,
|
|
|
- salt: Encoding.UTF8.GetBytes(salt), // SHA1鹽(8-20字節), SHA256(32字節)
|
|
|
- prf: KeyDerivationPrf.HMACSHA1,
|
|
|
- iterationCount: 10000, // hash次數,越多次代表破解難度變高,但效能差點
|
|
|
- numBytesRequested: 256 / 8 // 指定得出結果長度
|
|
|
- );
|
|
|
- String hashText = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
|
|
|
- return hashText;
|
|
|
- }
|
|
|
}
|
|
|
}
|