UI for Zipcoin Blue

browser.js 625B

12345678910111213141516171819202122232425262728293031
  1. 'use strict'
  2. var inherits = require('inherits')
  3. var MD5 = require('md5.js')
  4. var RIPEMD160 = require('ripemd160')
  5. var sha = require('sha.js')
  6. var Base = require('cipher-base')
  7. function Hash (hash) {
  8. Base.call(this, 'digest')
  9. this._hash = hash
  10. }
  11. inherits(Hash, Base)
  12. Hash.prototype._update = function (data) {
  13. this._hash.update(data)
  14. }
  15. Hash.prototype._final = function () {
  16. return this._hash.digest()
  17. }
  18. module.exports = function createHash (alg) {
  19. alg = alg.toLowerCase()
  20. if (alg === 'md5') return new MD5()
  21. if (alg === 'rmd160' || alg === 'ripemd160') return new RIPEMD160()
  22. return new Hash(sha(alg))
  23. }