mirror of
https://github.com/Kunzisoft/KeePassDX.git
synced 2026-11-26 20:06:37 -08:00
clean up
This commit is contained in:
1 parent
e5d58721dd
commit
3b967dd4e3
25 files changed
+379
-208
No files matched your search
@@ -1008,7 +1008,7 @@ class Database(private val iconPackChooser: InterfaceIconPackChooser) {
|
||||
}
|
||||
|
||||
fun clearAndClose(context: Context? = null) {
|
||||
clearIndexesAndBinaries(context?.let { com.kunzisoft.keepass.utils.UriUtilDatabase.getBinaryDir(context) })
|
||||
clearIndexesAndBinaries(context?.let { UriUtilDatabase.getBinaryDir(context) })
|
||||
this.mDatabaseKDB = null
|
||||
this.mDatabaseKDBX = null
|
||||
this.fileUri = null
|
||||
|
||||
-1
@@ -20,7 +20,6 @@ package com.kunzisoft.keepass.database.element.template
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Color
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.database.R
|
||||
import com.kunzisoft.keepass.database.element.Field
|
||||
import com.kunzisoft.keepass.database.element.database.DatabaseKDBX
|
||||
import com.kunzisoft.keepass.database.element.entry.EntryKDBX
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
package com.kunzisoft.keepass.database.file.input
|
||||
|
||||
import android.util.Log
|
||||
import com.kunzisoft.keepass.database.R
|
||||
import com.kunzisoft.keepass.database.element.database.DatabaseVersioned
|
||||
import com.kunzisoft.keepass.database.exception.DatabaseInputException
|
||||
import com.kunzisoft.keepass.tasks.ProgressTaskUpdater
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Copyright 2022 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePassDX.
|
||||
*
|
||||
* KeePassDX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePassDX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.model
|
||||
|
||||
import android.net.Uri
|
||||
@@ -9,13 +28,12 @@ import com.kunzisoft.keepass.utils.writeEnum
|
||||
class CipherDecryptDatabase(): Parcelable {
|
||||
|
||||
var databaseUri: Uri? = null
|
||||
var credentialStorage: com.kunzisoft.keepass.model.CredentialStorage =
|
||||
com.kunzisoft.keepass.model.CredentialStorage.Companion.DEFAULT
|
||||
var credentialStorage: CredentialStorage = CredentialStorage.DEFAULT
|
||||
var decryptedValue: ByteArray = byteArrayOf()
|
||||
|
||||
constructor(parcel: Parcel): this() {
|
||||
databaseUri = parcel.readParcelable(Uri::class.java.classLoader)
|
||||
credentialStorage = parcel.readEnum<com.kunzisoft.keepass.model.CredentialStorage>() ?: credentialStorage
|
||||
credentialStorage = parcel.readEnum<CredentialStorage>() ?: credentialStorage
|
||||
decryptedValue = ByteArray(parcel.readInt())
|
||||
parcel.readByteArray(decryptedValue)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Copyright 2022 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePassDX.
|
||||
*
|
||||
* KeePassDX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePassDX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.model
|
||||
|
||||
import android.net.Uri
|
||||
@@ -9,14 +28,13 @@ import com.kunzisoft.keepass.utils.writeEnum
|
||||
class CipherEncryptDatabase(): Parcelable {
|
||||
|
||||
var databaseUri: Uri? = null
|
||||
var credentialStorage: com.kunzisoft.keepass.model.CredentialStorage =
|
||||
com.kunzisoft.keepass.model.CredentialStorage.Companion.DEFAULT
|
||||
var credentialStorage: CredentialStorage = CredentialStorage.DEFAULT
|
||||
var encryptedValue: ByteArray = byteArrayOf()
|
||||
var specParameters: ByteArray = byteArrayOf()
|
||||
|
||||
constructor(parcel: Parcel): this() {
|
||||
databaseUri = parcel.readParcelable(Uri::class.java.classLoader)
|
||||
credentialStorage = parcel.readEnum<com.kunzisoft.keepass.model.CredentialStorage>() ?: credentialStorage
|
||||
credentialStorage = parcel.readEnum<CredentialStorage>() ?: credentialStorage
|
||||
encryptedValue = ByteArray(parcel.readInt())
|
||||
parcel.readByteArray(encryptedValue)
|
||||
specParameters = ByteArray(parcel.readInt())
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Copyright 2017 Brian Pellin, Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePassDX.
|
||||
*
|
||||
* KeePassDX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePassDX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.stream
|
||||
|
||||
import java.io.IOException
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Copyright 2019 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePassDX.
|
||||
*
|
||||
* KeePassDX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePassDX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.tasks
|
||||
|
||||
import android.os.Bundle
|
||||
|
||||
@@ -1,3 +1,22 @@
|
||||
/*
|
||||
* Copyright 2019 Jeremy Jamet / Kunzisoft.
|
||||
*
|
||||
* This file is part of KeePassDX.
|
||||
*
|
||||
* KeePassDX is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* KeePassDX is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with KeePassDX. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.kunzisoft.keepass.timeout
|
||||
|
||||
import android.app.AlarmManager
|
||||
|
||||
@@ -193,6 +193,20 @@ fun bytes4ToUInt(buf: ByteArray): UnsignedInt {
|
||||
+ (buf[3].toInt() and 0xFF shl 24))
|
||||
}
|
||||
|
||||
fun bytes16ToUuid(buf: ByteArray): UUID {
|
||||
var lsb: Long = 0
|
||||
for (i in 15 downTo 8) {
|
||||
lsb = lsb shl 8 or (buf[i].toLong() and 0xff)
|
||||
}
|
||||
|
||||
var msb: Long = 0
|
||||
for (i in 7 downTo 0) {
|
||||
msb = msb shl 8 or (buf[i].toLong() and 0xff)
|
||||
}
|
||||
|
||||
return UUID(msb, lsb)
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpack date from 5 byte format. The five bytes at 'offset' are unpacked
|
||||
* to a java.util.Date instance.
|
||||
@@ -251,6 +265,14 @@ fun uLongTo8Bytes(value: UnsignedLong): ByteArray {
|
||||
return longTo8Bytes(value.toKotlinLong())
|
||||
}
|
||||
|
||||
fun longTo8Bytes(value: Long): ByteArray {
|
||||
val buf = ByteArray(8)
|
||||
for (i in 0 until 8) {
|
||||
buf[i] = (value.ushr(8 * i) and 0xFF).toByte()
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
fun uuidTo16Bytes(uuid: UUID): ByteArray {
|
||||
val buf = ByteArray(16)
|
||||
for (i in 0 until 8) {
|
||||
@@ -329,25 +351,3 @@ fun writeStringToStream(outputStream: OutputStream, string: String?): Int {
|
||||
|
||||
return length
|
||||
}
|
||||
|
||||
fun bytes16ToUuid(buf: ByteArray): UUID {
|
||||
var lsb: Long = 0
|
||||
for (i in 15 downTo 8) {
|
||||
lsb = lsb shl 8 or (buf[i].toLong() and 0xff)
|
||||
}
|
||||
|
||||
var msb: Long = 0
|
||||
for (i in 7 downTo 0) {
|
||||
msb = msb shl 8 or (buf[i].toLong() and 0xff)
|
||||
}
|
||||
|
||||
return UUID(msb, lsb)
|
||||
}
|
||||
|
||||
fun longTo8Bytes(value: Long): ByteArray {
|
||||
val buf = ByteArray(8)
|
||||
for (i in 0 until 8) {
|
||||
buf[i] = (value.ushr(8 * i) and 0xFF).toByte()
|
||||
}
|
||||
return buf
|
||||
}
|
||||
Reference in new issue
Block a user