© 2005 Goetz Heller
Table of Contents Examples Source Code Subclass Template Copyright Note backhashAlgorithm is a generic helper class whose primary purpose is to manage hash algorithms. Its design was losely inspired by that of Microsoft's abstract .Net class HashAlgorithm. It works as an abstract base class from which concrete hash algorithms are derived via prototype inheritance. Instances of a concrete hash algorithm class should not be created directly using the new operator - use hashAlgorithm as a class factory and call hashAlgorithm.create() instead passing the name of the hash algorithm as parameter. This ensures that the new instance will be initialized properly. Furthermore, a loader function can be installed which requests the JavaScript code of an algorithm from a server if it has not yet been installed (load on demand).
Any hash algorithm to be managed by this class is required to do the following:
core.derive(xxx, hashAlgorithm);where "
xxx" denotes the algorithm class
this.buildHash();into the body of its hashFinal() method as last statement before successfully returning
this.sup.init();at the end of its body
Replacing the protoype provides instances of the installed hash algorithm with the following: