Skip to content

Instantly share code, notes, and snippets.

@gabro
Created July 22, 2020 05:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabro/58112395c41a2382e1b63d9ff81d690f to your computer and use it in GitHub Desktop.
Save gabro/58112395c41a2382e1b63d9ff81d690f to your computer and use it in GitHub Desktop.
Read string into keyring
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