mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
generating all IDs with secure method (important now since it's used as salt for encryption)
This commit is contained in:
parent
b81f1ed93a
commit
4187ff36fb
@ -304,9 +304,6 @@ const noteTree = (function() {
|
||||
|
||||
let parentNoteId = 'root';
|
||||
|
||||
console.log('notePath: ' + notePath);
|
||||
console.log('notePath chunks: ', notePath.split('/'));
|
||||
|
||||
for (const noteId of notePath.split('/')) {
|
||||
console.log('noteId: ' + noteId);
|
||||
|
||||
@ -315,8 +312,6 @@ const noteTree = (function() {
|
||||
parentNoteId = noteId;
|
||||
}
|
||||
|
||||
console.log("Title path:", titlePath.join(' / '));
|
||||
|
||||
return titlePath.join(' / ');
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
const crypto = require('crypto');
|
||||
|
||||
function newNoteId() {
|
||||
return randomString(8);
|
||||
return randomString(12);
|
||||
}
|
||||
|
||||
function newNoteTreeId() {
|
||||
@ -14,16 +14,10 @@ function newNoteHistoryId() {
|
||||
return randomString(12);
|
||||
}
|
||||
|
||||
const ALPHA_NUMERIC = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
|
||||
|
||||
function randomString(length) {
|
||||
let result = '';
|
||||
const token = randomSecureToken(32);
|
||||
|
||||
for (let i = length; i > 0; --i) {
|
||||
result += ALPHA_NUMERIC[Math.floor(Math.random() * ALPHA_NUMERIC.length)];
|
||||
}
|
||||
|
||||
return result;
|
||||
return token.substr(0, length);
|
||||
}
|
||||
|
||||
function randomSecureToken(bytes = 32) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user