decrypt Data with RSA private key - Java Security

Java examples for Security:RSA

Description

decrypt Data with RSA private key

Demo Code


//package com.java2s;

import java.security.PrivateKey;

import javax.crypto.Cipher;

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

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

Related Tutorials