public static byte[] sign(byte[] contentByteArray, PrivateKey privateKey) {
        try {
            Signature signature = Signature.getInstance(signAlgorithm);
            signature.initSign(privateKey);
            signature.update(contentByteArray);
            return signature.sign();
        } catch (NoSuchAlgorithmException e) {
            e.printStackTrace();
        } catch (SignatureException e) {
            e.printStackTrace();
        } catch (InvalidKeyException e) {
            e.printStackTrace();
        }
        return null;
    }
public static byte [ ] sign ( byte [ ] contentByteArray , PrivateKey privateKey ) { try { Signature signature = Signature . getInstance ( signAlgorithm ) ; signature . initSign ( privateKey ) ; signature . update ( contentByteArray ) ; return signature . sign ( ) ; } catch ( NoSuchAlgorithmException e ) { e . printStackTrace ( ) ; } catch ( SignatureException e ) { e . printStackTrace ( ) ; } catch ( InvalidKeyException e ) { e . printStackTrace ( ) ; } return null ; }
对内容进行加签
<p>Function: encrypt</p>
<p>Description: </p>

@param contentByteArray 明文
@param privateKey       私钥
@return
@throws NoSuchAlgorithmException
@throws InvalidKeyException
@throws SignatureException
@throws UnsupportedEncodingException
@author acexy@thankjava.com
@date 2016年8月10日 下午5:41:51
@version 1.0