public String sign(String content, PrivateKey privateKey) {

        if (content == null) {
            return null;
        }

        byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
        InputStream input = new ByteArrayInputStream(bytes);
        return sign(input, privateKey);
        // ByteArrayInputStream does not need to be closed.
    }
public String sign ( String content , PrivateKey privateKey ) { if ( content == null ) { return null ; } byte [ ] bytes = content . getBytes ( StandardCharsets . UTF_8 ) ; InputStream input = new ByteArrayInputStream ( bytes ) ; return sign ( input , privateKey ) ; }
Generates a digital signature for the given string.

@param content    The string to be digitally signed.
@param privateKey The {@link PrivateKey} with which the string is to be signed. This can be obtained
via {@link Keys#newKeyPair()}.
@return The signature as a base64-encoded string. If the content is null, null is returned.