mirror of
https://github.com/android-password-store/Android-Password-Store
synced 2025-08-30 13:57:47 +00:00
Add KeyUtils#tryGetEmail
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
package app.passwordstore.crypto
|
||||
|
||||
import app.passwordstore.crypto.GpgIdentifier.KeyId
|
||||
import app.passwordstore.crypto.GpgIdentifier.UserId
|
||||
import com.github.michaelbull.result.get
|
||||
import com.github.michaelbull.result.runCatching
|
||||
import org.bouncycastle.openpgp.PGPKeyRing
|
||||
@@ -34,4 +35,9 @@ public object KeyUtils {
|
||||
val keyRing = tryParseKeyring(key) ?: return null
|
||||
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