java - Unable to load RSA public key -
i'm trying read rsa public key shown below, exception @ line 6: java.security.spec.invalidkeyspecexception: java.security.invalidkeyexception: ioexception: algid parse error, not sequence my code: string rsapublickey = rsapublickeystring.replace( "-----begin rsa public key-----\n", ""); rsapublickey = rsapublickey.replace("\n-----end rsa public key-----", ""); byte[] bytes = encryptionutils.decodebase64(rsapublickey); keyfactory keyfactory = keyfactory.getinstance("rsa"); x509encodedkeyspec keyspec = new x509encodedkeyspec(bytes); pubkey = (rsapublickey)keyfactory.generatepublic(keyspec); rsa public key: -----begin rsa public key----- miibcgkcaqeawvacpi9w23mf3tbkdzz+zwrzkoaaqdr01vabu4e1pvkfj4sqdsm6 lydons789svod/xcs9y0hkkc3gtl1tsftlgcmooul9lcixlekzwkenj1yz/s7das an9tqw3bfuv/nqgbhgx81v/+7rfaed+rwfnk7a+xyl9sluzhryvvattveb2gaztw efzk2dwgkbluml8oremvfrax3bkhzjtkx4eqsjbbbdj2zxisrryoxfaa+xayegb+ 8hdllmajbcvfaigxx0cdqwer1y...