Android examples for java.security:RSA
rsa Verify
//package com.java2s; import java.security.KeyFactory; import java.security.PublicKey; import java.security.spec.X509EncodedKeySpec; import android.util.Base64; public class Main { /**// ww w . j a v a 2s. c o m * rsaVerify * @param content * @param sign * @param publicKey * @return * @throws Exception */ public static boolean rsaVerify(byte[] content, byte[] sign, byte[] publicKey) throws Exception { KeyFactory keyFactory = KeyFactory.getInstance("RSA"); byte[] encodedKey = Base64.decode(publicKey, Base64.DEFAULT); PublicKey publicKeyObj = keyFactory .generatePublic(new X509EncodedKeySpec(encodedKey)); java.security.Signature signature = java.security.Signature .getInstance("SHA1WithRSA"); signature.initVerify(publicKeyObj); signature.update(content); return signature.verify(sign); } }