public static String encryptByPrivateKey(String data, String privateKey) throws Exception {
		PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec(base64.decode(privateKey));
		KeyFactory keyf = KeyFactory.getInstance("RSA");
		PrivateKey priKey = keyf.generatePrivate(priPKCS8);
		java.security.Signature signature = java.security.Signature.getInstance("SHA256WithRSA");

		signature.initSign(priKey);
		signature.update(data.getBytes("UTf-8"));
		byte[] signed = signature.sign();
		return base64.encodeToString(signed);
	}
public static String encryptByPrivateKey ( String data , String privateKey ) throws Exception { PKCS8EncodedKeySpec priPKCS8 = new PKCS8EncodedKeySpec ( base64 . decode ( privateKey ) ) ; KeyFactory keyf = KeyFactory . getInstance ( "RSA" ) ; PrivateKey priKey = keyf . generatePrivate ( priPKCS8 ) ; java . security . Signature signature = java . security . Signature . getInstance ( "SHA256WithRSA" ) ; signature . initSign ( priKey ) ; signature . update ( data . getBytes ( "UTf-8" ) ) ; byte [ ] signed = signature . sign ( ) ; return base64 . encodeToString ( signed ) ; }
私钥签名

@param data
@param privateKey
@return
@throws Exception