mirror of
https://github.com/danog/fast-srp.git
synced 2024-12-02 09:17:46 +01:00
Fixup for node v0.12.7
This commit is contained in:
parent
c0b32d8e78
commit
99e62191dc
37
lib/jsbn.js
37
lib/jsbn.js
@ -32,6 +32,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
*
|
||||||
|
* Copyright (c) 2015 Zarmack Tanen
|
||||||
|
* Fixed .toString(16) to be compatible with node >0.12.7 because hexWrite()
|
||||||
|
* only accepts %2=0 strings
|
||||||
|
*
|
||||||
|
*
|
||||||
* Added Node.js Buffers support
|
* Added Node.js Buffers support
|
||||||
* 2014 rzcoder
|
* 2014 rzcoder
|
||||||
*/
|
*/
|
||||||
@ -286,8 +292,9 @@ function bnToString(b) {
|
|||||||
if (m) r += int2char(d);
|
if (m) r += int2char(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(r.length == 1)
|
//! Fix to be compatible with node >0.12.7 Buffer.js
|
||||||
r = '0' + r;
|
if(b == 16 && r.length % 2 != 0)
|
||||||
|
r = "0" + r;
|
||||||
return m ? r : "0";
|
return m ? r : "0";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,6 +321,27 @@ function bnCompareTo(a) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bnEqual(a) {
|
||||||
|
console.log(this.compareTo(a));
|
||||||
|
return (this.compareTo(a) == 0) ? true: false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bnGreater(a) {
|
||||||
|
return (this.compareTo(a) > 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bnGreaterOrEqual(a) {
|
||||||
|
return (this.compareTo(a) > 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bnLesser(a) {
|
||||||
|
return (this.compareTo(a) < 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function bnLesserOrEqual(a) {
|
||||||
|
return (this.compareTo(a) <= 0) ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
// returns bit length of the integer x
|
// returns bit length of the integer x
|
||||||
function nbits(x) {
|
function nbits(x) {
|
||||||
var r = 1, t;
|
var r = 1, t;
|
||||||
@ -1495,6 +1523,11 @@ BigInteger.prototype.signum = bnSigNum;
|
|||||||
BigInteger.prototype.toByteArray = bnToByteArray;
|
BigInteger.prototype.toByteArray = bnToByteArray;
|
||||||
BigInteger.prototype.toBuffer = bnToBuffer;
|
BigInteger.prototype.toBuffer = bnToBuffer;
|
||||||
BigInteger.prototype.equals = bnEquals;
|
BigInteger.prototype.equals = bnEquals;
|
||||||
|
BigInteger.prototype.eq = bnEqual;
|
||||||
|
BigInteger.prototype.gt = bnGreater;
|
||||||
|
BigInteger.prototype.gte = bnGreaterOrEqual;
|
||||||
|
BigInteger.prototype.lt = bnLesser;
|
||||||
|
BigInteger.prototype.lte = bnLesserOrEqual;
|
||||||
BigInteger.prototype.min = bnMin;
|
BigInteger.prototype.min = bnMin;
|
||||||
BigInteger.prototype.max = bnMax;
|
BigInteger.prototype.max = bnMax;
|
||||||
BigInteger.prototype.and = bnAnd;
|
BigInteger.prototype.and = bnAnd;
|
||||||
|
Loading…
Reference in New Issue
Block a user