1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-04-12 13:53:13 +00:00

Merge 8fdb2c6dec5de91d2feb892899bbef5c6ed9f320 into 961e74f73d230d0028efb586db07699120eac888

This commit is contained in:
Mario Pietsch 2025-04-04 15:00:28 +02:00 committed by GitHub
commit d316bc683a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -799,12 +799,13 @@ the password, and to encrypt/decrypt a block of text
$tw.utils.Crypto = function() {
var sjcl = $tw.node ? (global.sjcl || require("./sjcl.js")) : window.sjcl,
currentPassword = null,
callSjcl = function(method,inputText,password) {
callSjcl = function(method,inputText,password,options) {
options = options || {};
password = password || currentPassword;
var outputText;
try {
if(password) {
outputText = sjcl[method](password,inputText);
outputText = sjcl[method](password,inputText,options);
}
} catch(ex) {
console.log("Crypto error:" + ex);
@ -830,7 +831,8 @@ $tw.utils.Crypto = function() {
return !!currentPassword;
}
this.encrypt = function(text,password) {
return callSjcl("encrypt",text,password);
// set default ks:256 -- see: http://bitwiseshiftleft.github.io/sjcl/doc/convenience.js.html
return callSjcl("encrypt",text,password,{v:1,iter:10000,ks:256,ts:64,mode:"ccm",adata:"",cipher:"aes"});
};
this.decrypt = function(text,password) {
return callSjcl("decrypt",text,password);