use decryptString()

This commit is contained in:
zadam 2019-11-02 07:50:23 +01:00
parent 475fddeec1
commit b7b583ff04
5 changed files with 11 additions and 6 deletions

View File

@ -52,7 +52,7 @@ class Note extends Entity {
this.isContentAvailable = protectedSessionService.isProtectedSessionAvailable();
if (this.isContentAvailable) {
this.title = protectedSessionService.decrypt(this.title).toString();
this.title = protectedSessionService.decryptString(this.title);
}
else {
this.title = "[protected]";

View File

@ -37,7 +37,7 @@ class NoteRevision extends Entity {
if (this.isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) {
this.title = protectedSessionService.decrypt(this.title).toString();
this.title = protectedSessionService.decryptString(this.title);
}
else {
this.title = "[Protected]";

View File

@ -41,8 +41,8 @@ async function getRecentChanges() {
for (const change of recentChanges) {
if (change.current_isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) {
change.title = protectedSessionService.decrypt(change.title).toString();
change.current_title = protectedSessionService.decrypt(change.current_title).toString();
change.title = protectedSessionService.decryptString(change.title);
change.current_title = protectedSessionService.decryptString(change.current_title);
}
else {
change.title = change.current_title = "[Protected]";

View File

@ -54,7 +54,7 @@ async function loadProtectedNotes() {
protectedNoteTitles = await sql.getMap(`SELECT noteId, title FROM notes WHERE isDeleted = 0 AND isProtected = 1`);
for (const noteId in protectedNoteTitles) {
protectedNoteTitles[noteId] = protectedSessionService.decrypt(protectedNoteTitles[noteId]).toString();
protectedNoteTitles[noteId] = protectedSessionService.decryptString(protectedNoteTitles[noteId]);
}
}

View File

@ -37,7 +37,7 @@ function isProtectedSessionAvailable() {
function decryptNotes(notes) {
for (const note of notes) {
if (note.isProtected) {
note.title = decrypt(note.title).toString();
note.title = decrypt(note.title);
}
}
}
@ -50,12 +50,17 @@ function decrypt(cipherText) {
return dataEncryptionService.decrypt(getDataKey(), cipherText);
}
function decryptString(cipherText) {
return dataEncryptionService.decryptString(getDataKey(), cipherText);
}
module.exports = {
setDataKey,
getDataKey,
isProtectedSessionAvailable,
encrypt,
decrypt,
decryptString,
decryptNotes,
setProtectedSessionId
};