You now own your data. Backup/Restore use cleartext json.

This commit is contained in:
ultra
2013-06-22 22:01:00 -04:00
parent edba5605d1
commit df5b48a748
2 changed files with 40 additions and 10 deletions

View File

@@ -3,6 +3,10 @@
font-family: monospace; font-family: monospace;
} }
#backupText {
width: 100%;
}
#title { #title {
width: 100%; width: 100%;
} }

View File

@@ -209,21 +209,31 @@
} }
function restoreKVS() { function restoreKVS() {
var data = prompt("Please enter backup blob"); var data = prompt("Please enter backup blob (any already existing pads will be overwritten!)");
var d = JSON.parse(data) var d = JSON.parse(data)
for (var k in d) { for (var k in d) {
setKVSItem(k, d[k]);
setKVSItem(hashTitle(k), sjcl.encrypt(key, d[k], {iter: 2000, ks: 256}));
if ($.inArray(k, pads) == -1) {
pads.push(k);
addPadList(k);
} }
key = $("#password").val(); }
getKVSItem(hashSomething("pads"),padsLoaded); savePads();
} }
function doBackup() { function doBackup() {
backup = new Object(); backup = new Object();
backupWaiting = 1 + pads.length; backupWaiting = pads.length;
backupKVS(hashSomething("pads"));
for (var pad in pads) { for (var pad in pads) {
backupKVS(hashTitle(pads[pad])); getKVSItem(hashTitle(pads[pad]), function(data) {
backup[pads[pad]] = sjcl.decrypt(key, data);
backupWaiting--;
if (backupWaiting == 0) {
$("#backupDlg").modal();
$("#backupText").val(JSON.stringify(backup))
}
});
} }
} }
@@ -295,6 +305,9 @@
// set up buttons // set up buttons
$("#backupCloseBtn").click(function () {
$("#backupDlg").modal("hide")
})
$("#backuper").click(doBackup); $("#backuper").click(doBackup);
$("#restorer").click(restoreKVS); $("#restorer").click(restoreKVS);
$("#submitter").click(saveNote); $("#submitter").click(saveNote);
@@ -311,6 +324,19 @@
</script> </script>
</head> </head>
<body> <body>
<div class="modal hide" id="backupDlg">
<div class="modal-header">
<h3>Backup</h3>
</div>
<div class="modal-body">
<textarea rows="10" id="backupText">
</textarea>
</div>
<div class="modal-footer">
<button id="backupCloseBtn" class="btn btn-primary">Done</button>
</div>
</div>
<div class="modal" id="myModal"> <div class="modal" id="myModal">
<div class="modal-header"> <div class="modal-header">
<h3>Login to CryptoPad</h3> <h3>Login to CryptoPad</h3>