I have a question about the conversion of a private key (.pem) in Base64. I saw that to generate a PrivateKey in Java/Scala through KeyFactory, I have to delete "-----BEGIN PRIVATE KEY-----" and "-----END PRIVATE KEY-----" lines manually before to convert privateKey.pem to Base64 format. Is there some function/method/class that executes this deletion automatically?
P.S.: Unfortunately, I can't use BouncyCastle library at the moment.