UNPKG

1.92 kBJavaScriptView Raw
1;(function (root, factory, undef) {
2 if (typeof exports === "object") {
3 // CommonJS
4 module.exports = exports = factory(require("./core"), require("./sha256"));
5 }
6 else if (typeof define === "function" && define.amd) {
7 // AMD
8 define(["./core", "./sha256"], factory);
9 }
10 else {
11 // Global (browser)
12 factory(root.CryptoJS);
13 }
14}(this, function (CryptoJS) {
15
16 (function () {
17 // Shortcuts
18 var C = CryptoJS;
19 var C_lib = C.lib;
20 var WordArray = C_lib.WordArray;
21 var C_algo = C.algo;
22 var SHA256 = C_algo.SHA256;
23
24 /**
25 * SHA-224 hash algorithm.
26 */
27 var SHA224 = C_algo.SHA224 = SHA256.extend({
28 _doReset: function () {
29 this._hash = new WordArray.init([
30 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
31 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4
32 ]);
33 },
34
35 _doFinalize: function () {
36 var hash = SHA256._doFinalize.call(this);
37
38 hash.sigBytes -= 4;
39
40 return hash;
41 }
42 });
43
44 /**
45 * Shortcut function to the hasher's object interface.
46 *
47 * @param {WordArray|string} message The message to hash.
48 *
49 * @return {WordArray} The hash.
50 *
51 * @static
52 *
53 * @example
54 *
55 * var hash = CryptoJS.SHA224('message');
56 * var hash = CryptoJS.SHA224(wordArray);
57 */
58 C.SHA224 = SHA256._createHelper(SHA224);
59
60 /**
61 * Shortcut function to the HMAC's object interface.
62 *
63 * @param {WordArray|string} message The message to hash.
64 * @param {WordArray|string} key The secret key.
65 *
66 * @return {WordArray} The HMAC.
67 *
68 * @static
69 *
70 * @example
71 *
72 * var hmac = CryptoJS.HmacSHA224(message, key);
73 */
74 C.HmacSHA224 = SHA256._createHmacHelper(SHA224);
75 }());
76
77
78 return CryptoJS.SHA224;
79
80}));
\No newline at end of file