Created
July 22, 2020 05:49
-
-
Save gabro/58112395c41a2382e1b63d9ff81d690f to your computer and use it in GitHub Desktop.
Read string into keyring
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.bouncycastle.openpgp.{ | |
PGPPublicKeyRing, | |
PGPPublicKeyRingCollection, | |
PGPUtil, | |
} | |
import org.bouncycastle.openpgp.operator.jcajce.JcaKeyFingerprintCalculator | |
def readPGPPublicKeys(pubKeys: List[String]): PGPPublicKeyRingCollection = { | |
val fingerprintCalculator = new JcaKeyFingerprintCalculator() | |
val publicKeyRings = pubKeys.map { pubKey => | |
new PGPPublicKeyRing( | |
PGPUtil.getDecoderStream(new ByteArrayInputStream(pubKey.getBytes)), | |
fingerprintCalculator, | |
) | |
} | |
new PGPPublicKeyRingCollection(publicKeyRings.asJavaCollection) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment