remove rusha dep

This commit is contained in:
Feross Aboukhadijeh 2014-07-02 15:23:48 -07:00
parent 6c7adecf25
commit 30b5380ce3
2 changed files with 8 additions and 6 deletions

View File

@ -1,14 +1,16 @@
var BitField = require('bitfield')
var bencode = require('bencode')
var BitField = require('bitfield')
var bufferEqual = require('buffer-equal')
var crypto = require('crypto')
var EventEmitter = require('events').EventEmitter
var inherits = require('inherits')
var Rusha = require('rusha-browserify') // Fast SHA1 (works in browser)
var BITFIELD_GROW = 1000
var PIECE_LENGTH = 16 * 1024
// Return sha1 hash **as a buffer**
function sha1 (buf) {
return (new Rusha()).digestFromBuffer(buf)
return crypto.createHash('sha1').update(buf).digest()
}
module.exports = function (metadata) {
@ -124,7 +126,7 @@ module.exports = function (metadata) {
} catch (err) {}
// check hash
if (this._infoHash && this._infoHash.toString('hex') !== sha1(metadata)) {
if (this._infoHash && !bufferEqual(this._infoHash, sha1(metadata))) {
return false
}

View File

@ -13,8 +13,8 @@
"dependencies": {
"bencode": "^0.6.0",
"bitfield": "^1.0.1",
"inherits": "^2.0.1",
"rusha-browserify": "^0.7.3"
"buffer-equal": "0.0.1",
"inherits": "^2.0.1"
},
"devDependencies": {
"bittorrent-protocol": "^1.0.0",