main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[d24f17c] | 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 | var Buffer = require('safe-buffer').Buffer
|
---|
| 13 |
|
---|
| 14 | var W = new Array(64)
|
---|
| 15 |
|
---|
| 16 | function Sha224 () {
|
---|
| 17 | this.init()
|
---|
| 18 |
|
---|
| 19 | this._w = W // new Array(64)
|
---|
| 20 |
|
---|
| 21 | Hash.call(this, 64, 56)
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | inherits(Sha224, Sha256)
|
---|
| 25 |
|
---|
| 26 | Sha224.prototype.init = function () {
|
---|
| 27 | this._a = 0xc1059ed8
|
---|
| 28 | this._b = 0x367cd507
|
---|
| 29 | this._c = 0x3070dd17
|
---|
| 30 | this._d = 0xf70e5939
|
---|
| 31 | this._e = 0xffc00b31
|
---|
| 32 | this._f = 0x68581511
|
---|
| 33 | this._g = 0x64f98fa7
|
---|
| 34 | this._h = 0xbefa4fa4
|
---|
| 35 |
|
---|
| 36 | return this
|
---|
| 37 | }
|
---|
| 38 |
|
---|
| 39 | Sha224.prototype._hash = function () {
|
---|
| 40 | var H = Buffer.allocUnsafe(28)
|
---|
| 41 |
|
---|
| 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 |
|
---|
| 50 | return H
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | module.exports = Sha224
|
---|
Note:
See
TracBrowser
for help on using the repository browser.