question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SHA instances aren't disposed

See original GitHub issue

AFAIU, 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:closed
  • Created 3 years ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
ChrisMcKeecommented, Apr 15, 2020

Tis in master

0reactions
andreimiltocommented, Apr 14, 2020
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found