RSA decrypt Data with private key - Android java.security

Android examples for java.security:RSA

Description

RSA decrypt Data with private key

Demo Code


//package com.java2s;

import java.security.PrivateKey;

import javax.crypto.Cipher;

public class Main {
    private static String RSA = "RSA";

    public static byte[] decryptData(byte[] encryptedData,
            PrivateKey privateKey) {
        try {//  ww w .  ja v a 2 s  . com
            Cipher cipher = Cipher.getInstance(RSA);
            cipher.init(Cipher.DECRYPT_MODE, privateKey);
            return cipher.doFinal(encryptedData);
        } catch (Exception e) {
            return null;
        }
    }
}

Related Tutorials