mirror of
https://github.com/seiichiro0185/sailotp.git
synced 2024-12-22 11:42:30 +00:00
Added AES-encryption for export/import
This commit is contained in:
parent
743b06f065
commit
0ea71dfb89
7 changed files with 1044 additions and 26 deletions
|
@ -28,7 +28,8 @@ OTHER_FILES += qml/harbour-sailotp.qml \
|
|||
qml/lib/crypto.js \
|
||||
qml/lib/sha.js \
|
||||
qml/sailotp.png \
|
||||
qml/pages/ExportPage.qml
|
||||
qml/pages/ExportPage.qml \
|
||||
qml/lib/gibberish-aes.js
|
||||
|
||||
HEADERS += \
|
||||
src/fileio.h
|
||||
|
|
1008
qml/lib/gibberish-aes.js
Normal file
1008
qml/lib/gibberish-aes.js
Normal file
File diff suppressed because it is too large
Load diff
|
@ -72,7 +72,7 @@ function getOTP() {
|
|||
}
|
||||
|
||||
// Get all OTP Values and put them into a JSON-Object
|
||||
function db2json(password) {
|
||||
function db2json() {
|
||||
var db = getDB();
|
||||
var otpList = [];
|
||||
|
||||
|
@ -97,7 +97,7 @@ function db2json(password) {
|
|||
}
|
||||
|
||||
// Read Values from JSON and put them into the DB
|
||||
function json2db(jsonString, password) {
|
||||
function json2db(jsonString) {
|
||||
var json = JSON.parse(jsonString);
|
||||
|
||||
if (json.version != "1" && json.app != "sailotp" ) {
|
||||
|
|
|
@ -72,12 +72,16 @@ Page {
|
|||
Qt.openUrlExternally("https://www.seiichiro0185.org/gitlab/seiichiro0185/harbour-sailotp.git")
|
||||
}
|
||||
}
|
||||
Text {
|
||||
id: accnowledgement
|
||||
TextArea {
|
||||
id: acknowledgement
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
anchors.top: homepage.bottom
|
||||
anchors.topMargin: 20
|
||||
text: "SailOTP uses the SHA-1 Implementation<br />from http://caligatio.github.io/jsSHA/"
|
||||
width: parent.width
|
||||
font.pixelSize: Theme.fontSizeSmall
|
||||
horizontalAlignment: TextEdit.Center
|
||||
readOnly: true
|
||||
text: "SailOTP uses the following third party libs:\n\nhttp://caligatio.github.io/jsSHA/\nhttps://github.com/mdp/gibberish-aes"
|
||||
color: "white"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import QtQuick 2.0
|
|||
import Sailfish.Silica 1.0
|
||||
import harbour.sailotp.FileIO 1.0 // Import FileIO Class
|
||||
import "../lib/storage.js" as DB // Import the storage library for Config-Access
|
||||
import "../lib/gibberish-aes.js" as Gibberish //Import AES encryption library
|
||||
|
||||
// Define Layout of the Export / Import Page
|
||||
Dialog {
|
||||
|
@ -40,7 +41,7 @@ Dialog {
|
|||
// We get the Object of the parent page on call to refresh it after adding a new Entry
|
||||
property QtObject parentPage: null
|
||||
|
||||
property string mode: "export"
|
||||
property string mode: "import"
|
||||
|
||||
// FileIO Object for reading / writing files
|
||||
FileIO {
|
||||
|
@ -61,14 +62,14 @@ Dialog {
|
|||
acceptText: mode == "export" ? "Export" : "Import"
|
||||
}
|
||||
|
||||
ComboBox {
|
||||
/*ComboBox {
|
||||
id: modeSel
|
||||
label: "Mode: "
|
||||
menu: ContextMenu {
|
||||
MenuItem { text: "Export"; onClicked: { mode = "export" } }
|
||||
MenuItem { text: "Import"; onClicked: { mode = "import" } }
|
||||
}
|
||||
}
|
||||
}*/
|
||||
TextField {
|
||||
id: fileName
|
||||
width: parent.width
|
||||
|
@ -97,11 +98,11 @@ Dialog {
|
|||
onDone: {
|
||||
if (result == DialogResult.Accepted) {
|
||||
if (mode == "export") {
|
||||
console.log("Exporting to " + fileName.text, filePassword.text);
|
||||
exportFile.write(DB.db2json());
|
||||
console.log("Exporting to " + fileName.text);
|
||||
exportFile.write(Gibberish.AES.enc(DB.db2json(), filePassword.text));
|
||||
} else if(mode == "import") {
|
||||
console.log("Importing ftom " + fileName.text, filePassword.text);
|
||||
DB.json2db(exportFile.read(), filePassword)
|
||||
console.log("Importing ftom " + fileName.text);
|
||||
DB.json2db(Gibberish.AES.dec(exportFile.read(), filePassword.text))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,11 +112,15 @@ Page {
|
|||
onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
|
||||
}
|
||||
MenuItem {
|
||||
text: "Export / Import DB"
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ExportPage.qml"), {parentPage: mainPage})
|
||||
text: "Export Token-DB"
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ExportPage.qml"), {parentPage: mainPage, mode: "export"})
|
||||
}
|
||||
MenuItem {
|
||||
text: "Add OTP"
|
||||
text: "Import Token-DB"
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("ExportPage.qml"), {parentPage: mainPage, mode: "import"})
|
||||
}
|
||||
MenuItem {
|
||||
text: "Add Token"
|
||||
onClicked: pageStack.push(Qt.resolvedUrl("AddOTP.qml"), {parentPage: mainPage})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,19 +15,19 @@ QMakeOptions:
|
|||
- VERSION=%{version}
|
||||
- RELEASE=%{release}
|
||||
PkgConfigBR:
|
||||
- Qt5Quick
|
||||
- Qt5Qml
|
||||
- Qt5Core
|
||||
- sailfishapp >= 0.0.10
|
||||
- Qt5Core
|
||||
- Qt5Qml
|
||||
- Qt5Quick
|
||||
Requires:
|
||||
- sailfishsilica-qt5 >= 0.10.9
|
||||
Files:
|
||||
- '%{_bindir}'
|
||||
- '%{_datadir}/%{name}/qml'
|
||||
- '%{_datadir}/applications/%{name}.desktop'
|
||||
- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
|
||||
- /usr/bin
|
||||
- /usr/share/harbour-sailotp
|
||||
- /usr/share/applications
|
||||
- /usr/share/icons/hicolor/86x86/apps
|
||||
- /usr/share/applications
|
||||
- /usr/share/harbour-sailotp
|
||||
- /usr/bin
|
||||
- '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png'
|
||||
- '%{_datadir}/applications/%{name}.desktop'
|
||||
- '%{_datadir}/%{name}/qml'
|
||||
- '%{_bindir}'
|
||||
PkgBR: []
|
||||
|
|
Loading…
Reference in a new issue