Some optimisations

Signed-off-by: Dominic Fischer <dominicfischer7@gmail.com>
This commit is contained in:
Dominic Fischer 2019-07-21 23:35:38 +01:00
parent 6d01a570fd
commit a34b053efe
2 changed files with 6 additions and 9 deletions

View file

@ -142,12 +142,11 @@ private fun deriveKey(password: String,
* Generate a 32 chars salt * Generate a 32 chars salt
*/ */
private fun generateSalt(): String { private fun generateSalt(): String {
var salt = "" val salt = buildString {
do { do {
salt += UUID.randomUUID().toString() append(UUID.randomUUID().toString())
} while (salt.length < SALT_LENGTH) } while (length < SALT_LENGTH)
}
return salt.substring(0, SALT_LENGTH) return salt.substring(0, SALT_LENGTH)
} }

View file

@ -63,10 +63,8 @@ data class MXKey(
fun signatureForUserId(userId: String, signkey: String): String? { fun signatureForUserId(userId: String, signkey: String): String? {
// sanity checks // sanity checks
if (userId.isNotBlank() && signkey.isNotBlank()) { if (userId.isNotBlank() && signkey.isNotBlank()) {
if (signatures.containsKey(userId)) {
return signatures[userId]?.get(signkey) return signatures[userId]?.get(signkey)
} }
}
return null return null
} }