public static String toPemFormat ( final PublicKey publicKey ) { final String publicKeyAsBase64String = toBase64 ( publicKey ) ; final List < String > parts = StringExtensions . splitByFixedLength ( publicKeyAsBase64String , 64 ) ; final StringBuilder sb = new StringBuilder ( ) ; sb . append ( PublicKeyReader . BEGIN_PUBLIC_KEY_PREFIX ) ; for ( final String part : parts ) { sb . append ( part ) ; sb . append ( System . lineSeparator ( ) ) ; } sb . append ( PublicKeyReader . END_PUBLIC_KEY_SUFFIX ) ; sb . append ( System . lineSeparator ( ) ) ; return sb . toString ( ) ; }
Transform the public key in pem format .