Here you can find the source of generateSHA1RSASignature(RSAPrivateKey privKey, byte[] text)
public static byte[] generateSHA1RSASignature(RSAPrivateKey privKey, byte[] text)
//package com.java2s; import java.security.*; import java.security.interfaces.RSAPrivateKey; public class Main { /**//w ww . ja v a2 s . c o m * Given the privateKey produce an RSA signature for the SHA1 hash of a given text. * * @return */ public static byte[] generateSHA1RSASignature(RSAPrivateKey privKey, byte[] text) { try { Signature mySig = Signature.getInstance("SHA1withRSA"); mySig.initSign(privKey); mySig.update(text); return mySig.sign(); } catch (Exception e) { // TODO: Improve error handling ... System.err.println("Exception in generateSHA1RSASignature: " + e); return null; } } }