|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
253 bytes
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 | const crypto = require('crypto');
|
|---|
| 3 |
|
|---|
| 4 | module.exports = length => {
|
|---|
| 5 | if (!Number.isFinite(length)) {
|
|---|
| 6 | throw new TypeError('Expected a finite number');
|
|---|
| 7 | }
|
|---|
| 8 |
|
|---|
| 9 | return crypto.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);
|
|---|
| 10 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.