@staticmethod<EOL><INDENT>def calculate_x509_fingerprint(x509_cert, alg='<STR_LIT>'):<DEDENT>
assert isinstance(x509_cert, compat.str_type)<EOL>lines = x509_cert.split('<STR_LIT:\n>')<EOL>data = '<STR_LIT>'<EOL>inData = False<EOL>for line in lines:<EOL><INDENT>line = line.rstrip()<EOL>if not inData:<EOL><INDENT>if line == '<STR_LIT>':<EOL><INDENT>inData = True<EOL><DEDENT>elif line == '<STR_LIT>' or line == '<STR_LIT>':<EOL><INDENT>return None<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if line == '<STR_LIT>':<EOL><INDENT>break<EOL><DEDENT>data += line<EOL><DEDENT><DEDENT>if not data:<EOL><INDENT>return None<EOL><DEDENT>decoded_data = base64.b64decode(compat.to_bytes(data))<EOL>if alg == '<STR_LIT>':<EOL><INDENT>fingerprint = sha512(decoded_data)<EOL><DEDENT>elif alg == '<STR_LIT>':<EOL><INDENT>fingerprint = sha384(decoded_data)<EOL><DEDENT>elif alg == '<STR_LIT>':<EOL><INDENT>fingerprint = sha256(decoded_data)<EOL><DEDENT>else:<EOL><INDENT>fingerprint = sha1(decoded_data)<EOL><DEDENT>return fingerprint.hexdigest().lower()<EOL>
Calculates the fingerprint of a formatted x509cert.

:param x509_cert: x509 cert formatted
:type: string

:param alg: The algorithm to build the fingerprint
:type: string

:returns: fingerprint
:rtype: string