Files

Return to Package Diff Home.
Brought to you by Intrinsic.

Package Diff: cryptiles @ 3.0.2 .. 3.1.0

lib/index.js

@@ -25,6 +25,21 @@
};
+// Return a random string of digits
+
+exports.randomDigits = function (size) {
+
+ const buffer = exports.randomBits(size * 8);
+ if (buffer instanceof Error) {
+ return buffer;
+ }
+
+ return buffer.map((v) => Math.floor(v / 25.6)).join('');
+};
+
+
+// Generate a buffer of random bits
+
exports.randomBits = function (bits) {
if (!bits ||

package.json

@@ -1,7 +1,7 @@
{
"name": "cryptiles",
"description": "General purpose crypto utilities",
- "version": "3.0.2",
+ "version": "3.1.0",
"repository": "git://github.com/hapijs/cryptiles",
"main": "lib/index.js",
"keywords": [
@@ -13,11 +13,11 @@
"node": ">=4.0.0"
},
"dependencies": {
- "boom": "3.x.x"
+ "boom": "4.x.x"
},
"devDependencies": {
"code": "3.x.x",
- "lab": "10.x.x"
+ "lab": "11.x.x"
},
"scripts": {
"test": "lab -a code -t 100 -L",

README.md

@@ -12,5 +12,8 @@
### `randomString(<Number> size)`
Returns a cryptographically strong pseudo-random data string. Takes a size argument for the length of the string.
+### `randomDigits(<Number> size)`
+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.