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(); this.isContentAvailable = protectedSessionService.isProtectedSessionAvailable();
if (this.isContentAvailable) { if (this.isContentAvailable) {
this.title = protectedSessionService.decrypt(this.title).toString(); this.title = protectedSessionService.decryptString(this.title);
} }
else { else {
this.title = "[protected]"; this.title = "[protected]";

View File

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

View File

@ -41,8 +41,8 @@ async function getRecentChanges() {
for (const change of recentChanges) { for (const change of recentChanges) {
if (change.current_isProtected) { if (change.current_isProtected) {
if (protectedSessionService.isProtectedSessionAvailable()) { if (protectedSessionService.isProtectedSessionAvailable()) {
change.title = protectedSessionService.decrypt(change.title).toString(); change.title = protectedSessionService.decryptString(change.title);
change.current_title = protectedSessionService.decrypt(change.current_title).toString(); change.current_title = protectedSessionService.decryptString(change.current_title);
} }
else { else {
change.title = change.current_title = "[Protected]"; 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`); protectedNoteTitles = await sql.getMap(`SELECT noteId, title FROM notes WHERE isDeleted = 0 AND isProtected = 1`);
for (const noteId in protectedNoteTitles) { 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) { function decryptNotes(notes) {
for (const note of notes) { for (const note of notes) {
if (note.isProtected) { 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); return dataEncryptionService.decrypt(getDataKey(), cipherText);
} }
function decryptString(cipherText) {
return dataEncryptionService.decryptString(getDataKey(), cipherText);
}
module.exports = { module.exports = {
setDataKey, setDataKey,
getDataKey, getDataKey,
isProtectedSessionAvailable, isProtectedSessionAvailable,
encrypt, encrypt,
decrypt, decrypt,
decryptString,
decryptNotes, decryptNotes,
setProtectedSessionId setProtectedSessionId
}; };