sha224.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. CryptoJS v3.1.2
  3. code.google.com/p/crypto-js
  4. (c) 2009-2013 by Jeff Mott. All rights reserved.
  5. code.google.com/p/crypto-js/wiki/License
  6. */
  7. (function () {
  8. // Shortcuts
  9. var C = CryptoJS;
  10. var C_lib = C.lib;
  11. var WordArray = C_lib.WordArray;
  12. var C_algo = C.algo;
  13. var SHA256 = C_algo.SHA256;
  14. /**
  15. * SHA-224 hash algorithm.
  16. */
  17. var SHA224 = C_algo.SHA224 = SHA256.extend({
  18. _doReset: function () {
  19. this._hash = new WordArray.init([
  20. 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
  21. 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
  22. ]);
  23. },
  24. _doFinalize: function () {
  25. var hash = SHA256._doFinalize.call(this);
  26. hash.sigBytes -= 4;
  27. return hash;
  28. }
  29. });
  30. /**
  31. * Shortcut function to the hasher's object interface.
  32. *
  33. * @param {WordArray|string} message The message to hash.
  34. *
  35. * @return {WordArray} The hash.
  36. *
  37. * @static
  38. *
  39. * @example
  40. *
  41. * var hash = CryptoJS.SHA224('message');
  42. * var hash = CryptoJS.SHA224(wordArray);
  43. */
  44. C.SHA224 = SHA256._createHelper(SHA224);
  45. /**
  46. * Shortcut function to the HMAC's object interface.
  47. *
  48. * @param {WordArray|string} message The message to hash.
  49. * @param {WordArray|string} key The secret key.
  50. *
  51. * @return {WordArray} The HMAC.
  52. *
  53. * @static
  54. *
  55. * @example
  56. *
  57. * var hmac = CryptoJS.HmacSHA224(message, key);
  58. */
  59. C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
  60. }());