private static PublicKey generatePublicKey(String encodedPublicKey) {
        try {
            byte[] decodedKey = Base64.decode(encodedPublicKey);
            KeyFactory keyFactory = KeyFactory.getInstance(KEY_FACTORY_ALGORITHM);

            return keyFactory.generatePublic(new X509EncodedKeySpec(decodedKey));
        } catch (NoSuchAlgorithmException e) {
            // This won't happen in an Android-compatible environment.
            throw new RuntimeException(e);
        } catch (Base64DecoderException e) {
            XLog.e(TAG, "Could not decode from Base64.");
            throw new IllegalArgumentException(e);
        } catch (InvalidKeySpecException e) {
            XLog.e(TAG, "Invalid key specification.");
            throw new IllegalArgumentException(e);
        }
    }
Generates a PublicKey instance from a string containing the Base64-encoded public key.

@param encodedPublicKey Base64-encoded public key
@throws IllegalArgumentException if encodedPublicKey is invalid
android/android_framework/base/src/main/java/com/google/android/vending/licensing/LicenseChecker.java