Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80556 views
1
/**
2
* A JavaScript implementation of the Secure Hash Algorithm, SHA-256, as defined
3
* in FIPS 180-2
4
* Version 2.2-beta Copyright Angel Marin, Paul Johnston 2000 - 2009.
5
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6
*
7
*/
8
9
var inherits = require('inherits')
10
var SHA256 = require('./sha256')
11
var Hash = require('./hash')
12
13
var W = new Array(64)
14
15
function Sha224() {
16
this.init()
17
18
this._w = W // new Array(64)
19
20
Hash.call(this, 64, 56)
21
}
22
23
inherits(Sha224, SHA256)
24
25
Sha224.prototype.init = function () {
26
this._a = 0xc1059ed8|0
27
this._b = 0x367cd507|0
28
this._c = 0x3070dd17|0
29
this._d = 0xf70e5939|0
30
this._e = 0xffc00b31|0
31
this._f = 0x68581511|0
32
this._g = 0x64f98fa7|0
33
this._h = 0xbefa4fa4|0
34
35
return this
36
}
37
38
Sha224.prototype._hash = function () {
39
var H = new Buffer(28)
40
41
H.writeInt32BE(this._a, 0)
42
H.writeInt32BE(this._b, 4)
43
H.writeInt32BE(this._c, 8)
44
H.writeInt32BE(this._d, 12)
45
H.writeInt32BE(this._e, 16)
46
H.writeInt32BE(this._f, 20)
47
H.writeInt32BE(this._g, 24)
48
49
return H
50
}
51
52
module.exports = Sha224
53
54