2016-10-01 12:33:37 +02:00
|
|
|
import QtQml 2.0
|
|
|
|
|
|
|
|
/**
|
2016-10-02 10:16:21 +02:00
|
|
|
* This script will "encrypt" and "decrypt" notes with ROT13
|
2016-10-01 12:33:37 +02:00
|
|
|
*/
|
|
|
|
QtObject {
|
2016-10-02 10:16:21 +02:00
|
|
|
/**
|
|
|
|
* This is called when the script is loaded by QOwnNotes
|
|
|
|
*/
|
|
|
|
function init() {
|
|
|
|
// disable the password dialog
|
|
|
|
script.encryptionDisablePassword();
|
|
|
|
}
|
|
|
|
|
2016-10-01 12:33:37 +02:00
|
|
|
/**
|
|
|
|
* This function is called when text has to be encrypted or decrypted
|
|
|
|
*
|
2017-06-03 10:08:57 +02:00
|
|
|
* @param text string the text to encrypt or decrypt
|
2016-10-01 12:33:37 +02:00
|
|
|
* @param password string the password
|
|
|
|
* @param decrypt bool if false encryption is demanded, if true decryption is demanded
|
2017-06-03 10:08:57 +02:00
|
|
|
* @return the encrypted decrypted text
|
2016-10-01 12:33:37 +02:00
|
|
|
*/
|
|
|
|
function encryptionHook(text, password, decrypt) {
|
|
|
|
// do the rot13 transformation
|
|
|
|
text = text.replace(/[a-zA-Z]/g, function(c){
|
|
|
|
return String.fromCharCode((c <= "Z" ? 90 : 122) >= (c = c.charCodeAt(0) + 13) ? c : c - 26);
|
|
|
|
});
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
}
|