Android examples for java.security:RSA
rsa Decrypt byte array
//package com.java2s; import javax.crypto.*; import java.security.*; public class Main { public static byte[] rsaDecrypt(byte[] data, Key key) { byte[] ret = null; if (data != null && data.length > 0 && key != null) { try { Cipher cipher = Cipher.getInstance("RSA"); cipher.init(Cipher.DECRYPT_MODE, key); ret = cipher.doFinal(data); } catch (NoSuchAlgorithmException e) { e.printStackTrace();//from w w w . jav a2s . c o m } catch (NoSuchPaddingException e) { e.printStackTrace(); } catch (InvalidKeyException e) { e.printStackTrace(); } catch (BadPaddingException e) { e.printStackTrace(); } catch (IllegalBlockSizeException e) { e.printStackTrace(); } } return ret; } }