Closed ghost closed 3 years ago
Digest: exported abstract class that all hashing algorithms inherit from. This is the outward-facing abstraction that is used to expose a neat API without all the implementation methods. BaseDigest: Another abstract class that inherits from Digest, except it has implementation methods that aren't relevant to the consumer of the API. All actual Digest classes inherit from this.
That's it. There's two levels of abstraction. Both of them are necessary because Dart doesn't have good privacy modifiers. This is just basic OO design.
SHA-3 function does need zero dependencies or abstactions, neither RSA or anything. But it has Digest, BaseDigest, Engine, then Instance. And Utils to be precise. If you need consistency in your project to have same interfaces you can use one level of abstraction. Bullshit. SHA-3 algorithm must be one file pure algorithm. And every other algorithm. Think about your life and maybe choose another profession.
Is SHA-3 a hashing algorithm? Yes. Do we have other hashing algorithms with parts that would be exactly the same? Yes.
Therefore, we abstract parts that are common across every hashing algorithm out into a new class, and make that class the superclass. This really isn't too difficult to understand.
The same logic, but RSA: is RSA an asymmetric encryption algorithm? Yes. Will any future asymmetric encryption algorithm we implement have common parts? Yes. In the interest of code quality, we abstract out the parts that are common to all asymmetric encryption algorithms.
Bullshit. SHA-3 algorithm must be one file pure algorithm. And every other algorithm.
What would that do? Force us to write more code, that's oftentimes repetitive, for no good reason.
Abstractions through abstractions through abstractions through abstractions through abstractions.