Java tutorial
//package com.java2s; //License from project: Apache License import android.util.Base64; import java.security.KeyFactory; import java.security.NoSuchAlgorithmException; import java.security.interfaces.RSAPublicKey; import java.security.spec.InvalidKeySpecException; import java.security.spec.X509EncodedKeySpec; public class Main { public static RSAPublicKey buildPublicKeyFromBase64String(String key) throws InvalidKeySpecException, NoSuchAlgorithmException { byte[] byteKey = Base64.decode(key.getBytes(), Base64.NO_WRAP | Base64.URL_SAFE); X509EncodedKeySpec X509publicKey = new X509EncodedKeySpec(byteKey); KeyFactory kf = KeyFactory.getInstance("RSA"); return (RSAPublicKey) kf.generatePublic(X509publicKey); } }