This repository has been archived by the owner on Apr 25, 2022. It is now read-only.
forked from kimbtech/KIMB-Notes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
138 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Diese Klasse dient Notizen zu ver- und entschluesseln. | ||
*/ | ||
class NotesEncrypter{ | ||
|
||
/** | ||
* >> Konstruktor << | ||
* lädt Daten aus dem localStorage sofern verfügbar. | ||
*/ | ||
constructor(){ | ||
if( localStorage.getItem("notes_encrypt_data") !== null ){ | ||
this.data = JSON.parse( localStorage.getItem("notes_encrypt_data") ); | ||
} | ||
else{ | ||
this.data = { | ||
password : "", | ||
status : false | ||
}; | ||
} | ||
} | ||
|
||
setNotesPassword( password ){ | ||
this.data.password = sjcl.codec.hex.fromBits( sjcl.hash.sha256.hash( password + "bu79ubwqrzbIgbuwiw" ) ); | ||
this.data.status = true; | ||
this.saveLocalStorage(); | ||
} | ||
|
||
requestForPassword(){ | ||
if(!this.data.status){ | ||
errorMessage( "Es ist kein Passwort zum Verschlüsseln von Notizen angegeben.", 20 ); | ||
} | ||
} | ||
|
||
encryptNote(text){ | ||
if(!this.data.status){ | ||
return text; | ||
} | ||
return JSON.stringify( sjcl.encrypt(this.data.password, text ) ); | ||
} | ||
|
||
decryptNote(text){ | ||
if(!this.data.status){ | ||
return text; | ||
} | ||
return sjcl.decrypt(this.data.password, JSON.parse( text ) ); | ||
} | ||
|
||
/** | ||
* >> PRIVATE << | ||
* Die internen Daten im localStorage ablegen. | ||
*/ | ||
saveLocalStorage(){ | ||
localStorage.setItem("notes_encrypt_data", JSON.stringify( this.data ) ); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters