String publickey = "TUlHZk1BMEdDU3FHU0liM0RRRUJBUVVBQTRHTkFEQ0JpUUtCZ1FDSmovRFYrN3QyM0dRZXNXRVpOYzd3cUtZQ2NpYnI1aGdWZlVpcEpxeEpEK3dveTBLY28yWnk5QURpT3lkVU9EcXJLUnUzNmFqQ3ROMU5tVlJUR0JkQzRaWGk3MUpTczY5VDJoaUxGaEtSSW5yaDNtZnVoUTc2SUJxNlQvMzlqZmFXNU0wOTZBQVlaSWNrN21xczNLdlRhUllHN2FZbHo3cGpyV0drcUNzNmNRSURBUUFC" ;
PublicKey key = Security.generatePublicKey(new String(Base64.decode(publickey)));
verified = Security. verify(key, signedData, signature);
Security.generatePublicKey 如下
public 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) {
throw new RuntimeException(e);
} catch (InvalidKeySpecException e) {
Log.e(TAG, "Invalid key specification.");
throw new IllegalArgumentException(e);
} catch (Base64DecoderException e) {
Log.e(TAG, "Base64 decoding failed.");
throw new IllegalArgumentException(e);
}
}
查看了一些资料 keyFactory.generatePublic(new X509EncodedKeySpec(decodedKey));有些不明了了