You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
670 B

4 years ago
  1. 'use strict';
  2. var utils = require('../utils');
  3. var SHA256 = require('./256');
  4. function SHA224() {
  5. if (!(this instanceof SHA224))
  6. return new SHA224();
  7. SHA256.call(this);
  8. this.h = [
  9. 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  10. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
  11. }
  12. utils.inherits(SHA224, SHA256);
  13. module.exports = SHA224;
  14. SHA224.blockSize = 512;
  15. SHA224.outSize = 224;
  16. SHA224.hmacStrength = 192;
  17. SHA224.padLength = 64;
  18. SHA224.prototype._digest = function digest(enc) {
  19. // Just truncate output
  20. if (enc === 'hex')
  21. return utils.toHex32(this.h.slice(0, 7), 'big');
  22. else
  23. return utils.split32(this.h.slice(0, 7), 'big');
  24. };