Android examples for java.security:RSA
RSA encrypt Data with Public key
//package com.java2s; import java.security.PublicKey; import javax.crypto.Cipher; public class Main { private static String RSA = "RSA"; public static byte[] encryptData(byte[] data, PublicKey publicKey) { try {/*from w w w .j a v a2 s .co m*/ Cipher cipher = Cipher.getInstance(RSA); cipher.init(Cipher.ENCRYPT_MODE, publicKey); return cipher.doFinal(data); } catch (Exception e) { e.printStackTrace(); return null; } } }