SHA instances aren't disposed
See original GitHub issueAFAIU, an instance of SHA256
, SHA384
or SHA512
should be disposed after use since it implements IDisposable
. E.g., in the documentation they wrap the SHA-related code with using
statement. I guess the same should be done here:
private static byte[] EnhancedHash(byte[] inputBytes, HashType hashType)
{
switch (hashType)
{
case HashType.SHA256:
inputBytes = SafeUTF8.GetBytes(Convert.ToBase64String(SHA256.Create().ComputeHash(inputBytes)));
break;
case HashType.SHA384:
inputBytes = SafeUTF8.GetBytes(Convert.ToBase64String(SHA384.Create().ComputeHash(inputBytes)));
break;
case HashType.SHA512:
inputBytes = SafeUTF8.GetBytes(Convert.ToBase64String(SHA512.Create().ComputeHash(inputBytes)));
break;
case HashType.Legacy384:
inputBytes = SHA384.Create().ComputeHash(inputBytes);
break;
default:
throw new ArgumentOutOfRangeException(nameof(hashType), hashType, null);
}
return inputBytes;
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top Results From Across the Web
Disposal — Autofac 7.0.0 documentation
A lifetime scope is created when a unit of work begins, and when that unit of work is complete the nested container can...
Read more >How and when are c# Static members disposed?
The static variable of your class are not garbage collected until the app domain hosting your class is unloaded. The Dispose() method will ......
Read more >Dependency injection guidelines - .NET
In the preceding code: The ExampleService instance is not created by the service container. The framework does not dispose of the services ...
Read more >Disposal of Religious Items
The proper disposal of votive candles and other devotionals, if they have been blessed, is to burn or to bury them, most preferably...
Read more >How to dispose of objects
Whenever you create an instance of a three.js type, you allocate a certain amount of memory. However, three.js creates for specific objects like...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Tis in master
@ChrisMcKee, 👍