sha224.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. (function() {
  2. var nodeEnv = typeof require !== 'undefined' && typeof process !== 'undefined';
  3. var __module = nodeEnv ? module : {exports:{}};
  4. var __filename = 'preview-scripts/__node_modules/sha.js/sha224.js';
  5. var __require = nodeEnv ? function (request) {
  6. return cc.require(request);
  7. } : function (request) {
  8. return __quick_compile_project__.require(request, __filename);
  9. };
  10. function __define (exports, require, module) {
  11. if (!nodeEnv) {__quick_compile_project__.registerModule(__filename, module);}/**
  12. * A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
  13. * in FIPS 180-2
  14. * Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
  15. * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
  16. *
  17. */
  18. var inherits = require('inherits')
  19. var Sha256 = require('./sha256')
  20. var Hash = require('./hash')
  21. var Buffer = require('safe-buffer').Buffer
  22. var W = new Array(64)
  23. function Sha224 () {
  24. this.init()
  25. this._w = W // new Array(64)
  26. Hash.call(this, 64, 56)
  27. }
  28. inherits(Sha224, Sha256)
  29. Sha224.prototype.init = function () {
  30. this._a = 0xc1059ed8
  31. this._b = 0x367cd507
  32. this._c = 0x3070dd17
  33. this._d = 0xf70e5939
  34. this._e = 0xffc00b31
  35. this._f = 0x68581511
  36. this._g = 0x64f98fa7
  37. this._h = 0xbefa4fa4
  38. return this
  39. }
  40. Sha224.prototype._hash = function () {
  41. var H = Buffer.allocUnsafe(28)
  42. H.writeInt32BE(this._a, 0)
  43. H.writeInt32BE(this._b, 4)
  44. H.writeInt32BE(this._c, 8)
  45. H.writeInt32BE(this._d, 12)
  46. H.writeInt32BE(this._e, 16)
  47. H.writeInt32BE(this._f, 20)
  48. H.writeInt32BE(this._g, 24)
  49. return H
  50. }
  51. module.exports = Sha224
  52. }
  53. if (nodeEnv) {
  54. __define(__module.exports, __require, __module);
  55. }
  56. else {
  57. __quick_compile_project__.registerModuleFunc(__filename, function () {
  58. __define(__module.exports, __require, __module);
  59. });
  60. }
  61. })();