mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-09-02 15:25:39 +00:00
Add KeyUtils#tryGetEmail
This commit is contained in:
@@ -6,6 +6,7 @@
|
|||||||
package app.passwordstore.crypto
|
package app.passwordstore.crypto
|
||||||
|
|
||||||
import app.passwordstore.crypto.GpgIdentifier.KeyId
|
import app.passwordstore.crypto.GpgIdentifier.KeyId
|
||||||
|
import app.passwordstore.crypto.GpgIdentifier.UserId
|
||||||
import com.github.michaelbull.result.get
|
import com.github.michaelbull.result.get
|
||||||
import com.github.michaelbull.result.runCatching
|
import com.github.michaelbull.result.runCatching
|
||||||
import org.bouncycastle.openpgp.PGPKeyRing
|
import org.bouncycastle.openpgp.PGPKeyRing
|
||||||
@@ -34,4 +35,9 @@ public object KeyUtils {
|
|||||||
val keyRing = tryParseKeyring(key) ?: return null
|
val keyRing = tryParseKeyring(key) ?: return null
|
||||||
return KeyId(keyRing.publicKey.keyID)
|
return KeyId(keyRing.publicKey.keyID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public fun tryGetEmail(key: PGPKey): UserId? {
|
||||||
|
val keyRing = tryParseKeyring(key) ?: return null
|
||||||
|
return UserId(keyRing.publicKey.userIDs.next())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user