Code example for RSAPublicKeySpec

0
	int exponentLength = readInt(keyByteArray, modulusLength + 4);
	byte[] exponentByteArray = new byte[exponentLength];
	System.arraycopy(keyByteArray, modulusLength + 8, exponentByteArray, 0, exponentLength);
	BigInteger publicExponent = new BigInteger(1, exponentByteArray);
 
	return KeyFactory.getInstance("RSA").generatePublic(new RSAPublicKeySpec(modulus, publicExponent));
    } 
 
    /** 
     * Encrypts given string with Google Public Key. 
     *  
     */ 
    public static String encryptString(String str2Encrypt) throws Exception {
 
	byte[] keyByteArray = Base64.decode(GOOGLE_PUBLIC_KEY, Base64.DEFAULT);
 
	byte[] header = new byte[5];
	byte[] digest = MessageDigest.getInstance("SHA-1").digest(keyByteArray);
	header[0] = 0;
	System.arraycopy(digest, 0, header, 1, 4);
Experience pair programming with AI  Get Codota for Java