+4
-1
@@ -287,3 +287,3 @@ // Utils | ||
| BN.prototype.toString = function toString(base) { | ||
| BN.prototype.toString = function toString(base, padding) { | ||
| base = base || 10; | ||
@@ -293,2 +293,3 @@ if (base === 16 || base === 'hex') { | ||
| var off = 0; | ||
| var padding = padding | 0 || 1; | ||
| var carry = 0; | ||
@@ -311,2 +312,4 @@ for (var i = 0; i < this.length; i++) { | ||
| out = carry.toString(16) + out; | ||
| while (out.length % padding !== 0) | ||
| out = '0' + out; | ||
| if (this.sign) | ||
@@ -313,0 +316,0 @@ out = '-' + out; |
+1
-1
| { | ||
| "name": "bn.js", | ||
| "version": "0.14.2", | ||
| "version": "0.15.0", | ||
| "description": "Big number implementation in pure javascript", | ||
@@ -5,0 +5,0 @@ "main": "lib/bn.js", |
+36
-0
@@ -73,2 +73,38 @@ var assert = require('assert'); | ||
| describe('hex padding', function(){ | ||
| it('should have length of 8 from leading 15', function(){ | ||
| var a = new BN('ffb9602', 16); | ||
| var b = new Buffer(a.toString('hex', 2), 'hex'); | ||
| assert.equal(a.toString('hex', 2).length, 8); | ||
| }); | ||
| it('should have length of 8 from leading zero', function(){ | ||
| var a = new BN('fb9604', 16); | ||
| var b = new Buffer(a.toString('hex', 8), 'hex'); | ||
| assert.equal(a.toString('hex', 8).length, 8); | ||
| }); | ||
| it('should have length of 8 from leading zeros', function(){ | ||
| var a = new BN(0); | ||
| var b = new Buffer(a.toString('hex', 8), 'hex'); | ||
| assert.equal(a.toString('hex', 8).length, 8); | ||
| }); | ||
| it('should have length of 64 from leading 15', function(){ | ||
| var a = new BN( | ||
| 'ffb96ff654e61130ba8422f0debca77a0ea74ae5ea8bca9b54ab64aabf01003', | ||
| 16); | ||
| var b = new Buffer(a.toString('hex', 2), 'hex'); | ||
| assert.equal(a.toString('hex', 2).length, 64); | ||
| }); | ||
| it('should have length of 64 from leading zero', function(){ | ||
| var a = new BN( | ||
| 'fb96ff654e61130ba8422f0debca77a0ea74ae5ea8bca9b54ab64aabf01003', | ||
| 16); | ||
| var b = new Buffer(a.toString('hex', 64), 'hex'); | ||
| assert.equal(a.toString('hex', 64).length, 64); | ||
| }); | ||
| }); | ||
| describe('iaddn', function() { | ||
@@ -75,0 +111,0 @@ it('should allow a sign change', function() { |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
63234
2.23%2052
1.68%