mirror of
https://github.com/seiichiro0185/sailotp.git
synced 2024-11-22 07:39:42 +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/crypto.js \
|
||||||
qml/lib/sha.js \
|
qml/lib/sha.js \
|
||||||
qml/sailotp.png \
|
qml/sailotp.png \
|
||||||
qml/pages/ExportPage.qml
|
qml/pages/ExportPage.qml \
|
||||||
|
qml/lib/gibberish-aes.js
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/fileio.h
|
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
|
// Get all OTP Values and put them into a JSON-Object
|
||||||
function db2json(password) {
|
function db2json() {
|
||||||
var db = getDB();
|
var db = getDB();
|
||||||
var otpList = [];
|
var otpList = [];
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ function db2json(password) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read Values from JSON and put them into the DB
|
// Read Values from JSON and put them into the DB
|
||||||
function json2db(jsonString, password) {
|
function json2db(jsonString) {
|
||||||
var json = JSON.parse(jsonString);
|
var json = JSON.parse(jsonString);
|
||||||
|
|
||||||
if (json.version != "1" && json.app != "sailotp" ) {
|
if (json.version != "1" && json.app != "sailotp" ) {
|
||||||
|
|
|
@ -72,12 +72,16 @@ Page {
|
||||||
Qt.openUrlExternally("https://www.seiichiro0185.org/gitlab/seiichiro0185/harbour-sailotp.git")
|
Qt.openUrlExternally("https://www.seiichiro0185.org/gitlab/seiichiro0185/harbour-sailotp.git")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Text {
|
TextArea {
|
||||||
id: accnowledgement
|
id: acknowledgement
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
anchors.top: homepage.bottom
|
anchors.top: homepage.bottom
|
||||||
anchors.topMargin: 20
|
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"
|
color: "white"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import QtQuick 2.0
|
||||||
import Sailfish.Silica 1.0
|
import Sailfish.Silica 1.0
|
||||||
import harbour.sailotp.FileIO 1.0 // Import FileIO Class
|
import harbour.sailotp.FileIO 1.0 // Import FileIO Class
|
||||||
import "../lib/storage.js" as DB // Import the storage library for Config-Access
|
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
|
// Define Layout of the Export / Import Page
|
||||||
Dialog {
|
Dialog {
|
||||||
|
@ -40,7 +41,7 @@ Dialog {
|
||||||
// We get the Object of the parent page on call to refresh it after adding a new Entry
|
// We get the Object of the parent page on call to refresh it after adding a new Entry
|
||||||
property QtObject parentPage: null
|
property QtObject parentPage: null
|
||||||
|
|
||||||
property string mode: "export"
|
property string mode: "import"
|
||||||
|
|
||||||
// FileIO Object for reading / writing files
|
// FileIO Object for reading / writing files
|
||||||
FileIO {
|
FileIO {
|
||||||
|
@ -61,14 +62,14 @@ Dialog {
|
||||||
acceptText: mode == "export" ? "Export" : "Import"
|
acceptText: mode == "export" ? "Export" : "Import"
|
||||||
}
|
}
|
||||||
|
|
||||||
ComboBox {
|
/*ComboBox {
|
||||||
id: modeSel
|
id: modeSel
|
||||||
label: "Mode: "
|
label: "Mode: "
|
||||||
menu: ContextMenu {
|
menu: ContextMenu {
|
||||||
MenuItem { text: "Export"; onClicked: { mode = "export" } }
|
MenuItem { text: "Export"; onClicked: { mode = "export" } }
|
||||||
MenuItem { text: "Import"; onClicked: { mode = "import" } }
|
MenuItem { text: "Import"; onClicked: { mode = "import" } }
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
TextField {
|
TextField {
|
||||||
id: fileName
|
id: fileName
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
@ -97,11 +98,11 @@ Dialog {
|
||||||
onDone: {
|
onDone: {
|
||||||
if (result == DialogResult.Accepted) {
|
if (result == DialogResult.Accepted) {
|
||||||
if (mode == "export") {
|
if (mode == "export") {
|
||||||
console.log("Exporting to " + fileName.text, filePassword.text);
|
console.log("Exporting to " + fileName.text);
|
||||||
exportFile.write(DB.db2json());
|
exportFile.write(Gibberish.AES.enc(DB.db2json(), filePassword.text));
|
||||||
} else if(mode == "import") {
|
} else if(mode == "import") {
|
||||||
console.log("Importing ftom " + fileName.text, filePassword.text);
|
console.log("Importing ftom " + fileName.text);
|
||||||
DB.json2db(exportFile.read(), filePassword)
|
DB.json2db(Gibberish.AES.dec(exportFile.read(), filePassword.text))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -112,11 +112,15 @@ Page {
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
|
onClicked: pageStack.push(Qt.resolvedUrl("About.qml"))
|
||||||
}
|
}
|
||||||
MenuItem {
|
MenuItem {
|
||||||
text: "Export / Import DB"
|
text: "Export Token-DB"
|
||||||
onClicked: pageStack.push(Qt.resolvedUrl("ExportPage.qml"), {parentPage: mainPage})
|
onClicked: pageStack.push(Qt.resolvedUrl("ExportPage.qml"), {parentPage: mainPage, mode: "export"})
|
||||||
}
|
}
|
||||||
MenuItem {
|
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})
|
onClicked: pageStack.push(Qt.resolvedUrl("AddOTP.qml"), {parentPage: mainPage})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,19 +15,19 @@ QMakeOptions:
|
||||||
- VERSION=%{version}
|
- VERSION=%{version}
|
||||||
- RELEASE=%{release}
|
- RELEASE=%{release}
|
||||||
PkgConfigBR:
|
PkgConfigBR:
|
||||||
- Qt5Quick
|
|
||||||
- Qt5Qml
|
|
||||||
- Qt5Core
|
|
||||||
- sailfishapp >= 0.0.10
|
- sailfishapp >= 0.0.10
|
||||||
|
- Qt5Core
|
||||||
|
- Qt5Qml
|
||||||
|
- Qt5Quick
|
||||||
Requires:
|
Requires:
|
||||||
- sailfishsilica-qt5 >= 0.10.9
|
- sailfishsilica-qt5 >= 0.10.9
|
||||||
Files:
|
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/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: []
|
PkgBR: []
|
||||||
|
|
Loading…
Reference in a new issue