Dispose IDisposable instances (#15810)
This commit is contained in:
@@ -16,8 +16,11 @@ public class LegacyPasswordSecurity
|
||||
public static string GenerateSalt()
|
||||
{
|
||||
var numArray = new byte[16];
|
||||
new RNGCryptoServiceProvider().GetBytes(numArray);
|
||||
return Convert.ToBase64String(numArray);
|
||||
using (var rng = new RNGCryptoServiceProvider())
|
||||
{
|
||||
rng.GetBytes(numArray);
|
||||
return Convert.ToBase64String(numArray);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Remove v11
|
||||
@@ -86,7 +89,7 @@ public class LegacyPasswordSecurity
|
||||
/// </summary>
|
||||
public bool VerifyLegacyHashedPassword(string password, string dbPassword)
|
||||
{
|
||||
var hashAlgorithm = new HMACSHA1
|
||||
using var hashAlgorithm = new HMACSHA1
|
||||
{
|
||||
// the legacy salt was actually the password :(
|
||||
Key = Encoding.Unicode.GetBytes(password),
|
||||
|
||||
@@ -98,7 +98,10 @@ public class PasswordGenerator
|
||||
var data = new byte[length];
|
||||
var chArray = new char[length];
|
||||
var num1 = 0;
|
||||
new RNGCryptoServiceProvider().GetBytes(data);
|
||||
using (var rng = new RNGCryptoServiceProvider())
|
||||
{
|
||||
rng.GetBytes(data);
|
||||
}
|
||||
|
||||
for (var index = 0; index < length; ++index)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user