make sure entity IDs are generated only with alphanumeric characters (base62)

This commit is contained in:
azivner
2017-12-09 20:44:06 -05:00
parent 372cce8f8e
commit f55f0a4ed3
6 changed files with 12 additions and 7 deletions

View File

@@ -1,6 +1,7 @@
"use strict";
const crypto = require('crypto');
const randtoken = require('rand-token').generator({source: 'crypto'});
function newNoteId() {
return randomString(12);
@@ -15,9 +16,7 @@ function newNoteHistoryId() {
}
function randomString(length) {
const token = randomSecureToken(32);
return token.substr(0, length);
return randtoken.generate(length);
}
function randomSecureToken(bytes = 32) {