@staticmethod<EOL><INDENT>def sign_binary(msg, key, algorithm=xmlsec.Transform.RSA_SHA1, debug=False):<DEDENT>
if isinstance(msg, str):<EOL><INDENT>msg = msg.encode('<STR_LIT:utf8>')<EOL><DEDENT>xmlsec.enable_debug_trace(debug)<EOL>dsig_ctx = xmlsec.SignatureContext()<EOL>dsig_ctx.key = xmlsec.Key.from_memory(key, xmlsec.KeyFormat.PEM, None)<EOL>return dsig_ctx.sign_binary(compat.to_bytes(msg), algorithm)<EOL>
Sign binary message

:param msg: The element we should validate
:type: bytes

:param key: The private key
:type: string

:param debug: Activate the xmlsec debug
:type: bool

:return signed message
:rtype str