@commercial/cryptiles
Advanced tools
Comparing version 3.2.0 to 4.2.1
@@ -16,6 +16,2 @@ 'use strict'; | ||
const buffer = exports.randomBits((size + 1) * 6); | ||
if (buffer instanceof Error) { | ||
return buffer; | ||
} | ||
const string = buffer.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, ''); | ||
@@ -30,26 +26,21 @@ return string.slice(0, size); | ||
try { | ||
const digits = []; | ||
const digits = []; | ||
let buffer = internals.random(size * 2); // Provision twice the amount of bytes needed to increase chance of single pass | ||
let pos = 0; | ||
let buffer = internals.random(size * 2); // Provision twice the amount of bytes needed to increase chance of single pass | ||
let pos = 0; | ||
while (digits.length < size) { | ||
if (pos >= buffer.length) { | ||
buffer = internals.random(size * 2); | ||
pos = 0; | ||
} | ||
while (digits.length < size) { | ||
if (pos >= buffer.length) { | ||
buffer = internals.random(size * 2); | ||
pos = 0; | ||
} | ||
if (buffer[pos] < 250) { | ||
digits.push(buffer[pos] % 10); | ||
} | ||
++pos; | ||
if (buffer[pos] < 250) { | ||
digits.push(buffer[pos] % 10); | ||
} | ||
return digits.join(''); | ||
++pos; | ||
} | ||
catch (err) { | ||
return err; | ||
} | ||
return digits.join(''); | ||
}; | ||
@@ -65,17 +56,10 @@ | ||
return Boom.internal('Invalid random bits count'); | ||
throw Boom.internal('Invalid random bits count'); | ||
} | ||
const bytes = Math.ceil(bits / 8); | ||
try { | ||
return internals.random(bytes); | ||
} | ||
catch (err) { | ||
return err; | ||
} | ||
return internals.random(bytes); | ||
}; | ||
// Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match) | ||
exports.fixedTimeComparison = function (a, b) { | ||
@@ -82,0 +66,0 @@ |
COMMERCIAL LICENSE | ||
Copyright (c) 2019 Sideway Inc. | ||
Copyright (c) 2019-2020 Sideway Inc. | ||
This package requires a commercial license. You may not use, copy, or distribute it without first acquiring a commercial license from Sideway Inc. Using this software without a license is a violation of US and international law. To obtain a license, please contact [sales@sideway.com](mailto:sales@sideway.com). | ||
This package contains code previously published under an open source license. You can find the previous materials and the terms under which they were originally published at: [https://github.com/hapijs/cryptiles/blob/master/LICENSE](https://github.com/hapijs/cryptiles/blob/master/LICENSE). | ||
This package contains code previously published under an open source license. You can find the previous materials and the terms under which they were originally published at: [https://github.com/hapijs/catbox-memory/blob/master/LICENSE](https://github.com/hapijs/cryptiles/blob/master/LICENSE). |
{ | ||
"name": "@commercial/cryptiles", | ||
"description": "General purpose crypto utilities", | ||
"version": "3.2.0", | ||
"version": "4.2.1", | ||
"repository": "git://github.com/hapijs/cryptiles", | ||
"engines": { | ||
"node": ">=8.0.0" | ||
}, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"keywords": [ | ||
@@ -12,14 +16,17 @@ "cryptography", | ||
], | ||
"files": [ | ||
"lib" | ||
], | ||
"dependencies": { | ||
"@commercial/boom": "5.x.x" | ||
"@commercial/boom": "^7.4.11" | ||
}, | ||
"devDependencies": { | ||
"code": "4.x.x", | ||
"lab": "14.x.x" | ||
"@hapi/code": "6.x.x", | ||
"@hapi/lab": "20.x.x" | ||
}, | ||
"scripts": { | ||
"test": "lab -a code -t 100 -m 30000 -l", | ||
"test-cov-html": "lab -a code -m 30000 -r html -o coverage.html -l" | ||
"test": "lab -a @hapi/code -t 100 -L -Y", | ||
"test-cov-html": "lab -a @hapi/code -t 100 -L -r html -o coverage.html" | ||
}, | ||
"license": "SEE LICENSE IN LICENSE.md" | ||
} |
@@ -1,11 +0,9 @@ | ||
# cryptiles | ||
<a href="http://hapijs.com"><img src="https://raw.githubusercontent.com/hapijs/assets/master/images/family.png" width="180px" align="right" /></a> | ||
# @hapi/cryptiles | ||
General purpose crypto utilities | ||
[![Build Status](https://travis-ci.org/hapijs/cryptiles.svg?branch=v3-commercial)](https://travis-ci.org/hapijs/cryptiles) | ||
[![Build Status](https://secure.travis-ci.org/hapijs/cryptiles.png)](http://travis-ci.org/hapijs/cryptiles) | ||
## License | ||
This version of the package requires a commercial license. You may not use, copy, or distribute it without first acquiring a commercial license from Sideway Inc. Using this software without a license is a violation of US and international law. To obtain a license, please contact [sales@sideway.com](mailto:sales@sideway.com). The open source version of this package can be found [here](https://github.com/hapijs/cryptiles). | ||
## Methods | ||
@@ -18,4 +16,1 @@ | ||
Returns a cryptographically strong pseudo-random data string consisting of only numerical digits (0-9). Takes a size argument for the length of the string. | ||
### `fixedTimeComparison(<String> a, <String> b)` | ||
Compare two strings using fixed time algorithm (to prevent time-based analysis of MAC digest match). Returns `true` if the strings match, `false` if they differ. |
77
16
+ Added@commercial/boom@7.4.12(transitive)
+ Added@commercial/hoek@8.5.1(transitive)
- Removed@commercial/boom@5.3.1(transitive)
- Removed@commercial/hoek@4.3.0(transitive)
Updated@commercial/boom@^7.4.11